Skip to content

Commit 3dfe114

Browse files
committed
nightly fmt
1 parent 7ae478c commit 3dfe114

File tree

3 files changed

+36
-42
lines changed

3 files changed

+36
-42
lines changed

src/impl_constructors.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ use rawpointer::PointerExt;
4444
///
4545
/// ## Constructor methods for one-dimensional arrays.
4646
impl<S, A> ArrayBase<S, Ix1>
47-
where
48-
S: DataOwned<Elem = A>,
47+
where S: DataOwned<Elem = A>
4948
{
5049
/// Create a one-dimensional array from a vector (no copying needed).
5150
///
@@ -56,7 +55,8 @@ where
5655
///
5756
/// let array = Array::from_vec(vec![1., 2., 3., 4.]);
5857
/// ```
59-
pub fn from_vec(v: Vec<A>) -> Self {
58+
pub fn from_vec(v: Vec<A>) -> Self
59+
{
6060
if mem::size_of::<A>() == 0 {
6161
assert!(v.len() <= isize::MAX as usize, "Length must fit in `isize`.",);
6262
}
@@ -73,7 +73,8 @@ where
7373
/// let array = Array::from_iter(0..10);
7474
/// ```
7575
#[allow(clippy::should_implement_trait)]
76-
pub fn from_iter<I: IntoIterator<Item = A>>(iterable: I) -> Self {
76+
pub fn from_iter<I: IntoIterator<Item = A>>(iterable: I) -> Self
77+
{
7778
Self::from_vec(iterable.into_iter().collect())
7879
}
7980

@@ -116,8 +117,7 @@ where
116117
/// ```
117118
#[cfg(feature = "std")]
118119
pub fn range(start: A, end: A, step: A) -> Self
119-
where
120-
A: Float,
120+
where A: Float
121121
{
122122
Self::from(to_vec(linspace::range(start, end, step)))
123123
}
@@ -181,17 +181,15 @@ where
181181
/// ```
182182
#[cfg(feature = "std")]
183183
pub fn geomspace(start: A, end: A, n: usize) -> Option<Self>
184-
where
185-
A: Float,
184+
where A: Float
186185
{
187186
Some(Self::from(to_vec(geomspace::geomspace(start, end, n)?)))
188187
}
189188
}
190189

191190
/// ## Constructor methods for two-dimensional arrays.
192191
impl<S, A> ArrayBase<S, Ix2>
193-
where
194-
S: DataOwned<Elem = A>,
192+
where S: DataOwned<Elem = A>
195193
{
196194
/// Create an identity matrix of size `n` (square 2D array).
197195
///
@@ -473,14 +471,14 @@ where
473471
/// );
474472
/// ```
475473
pub fn from_shape_vec<Sh>(shape: Sh, v: Vec<A>) -> Result<Self, ShapeError>
476-
where
477-
Sh: Into<StrideShape<D>>,
474+
where Sh: Into<StrideShape<D>>
478475
{
479476
// eliminate the type parameter Sh as soon as possible
480477
Self::from_shape_vec_impl(shape.into(), v)
481478
}
482479

483-
fn from_shape_vec_impl(shape: StrideShape<D>, v: Vec<A>) -> Result<Self, ShapeError> {
480+
fn from_shape_vec_impl(shape: StrideShape<D>, v: Vec<A>) -> Result<Self, ShapeError>
481+
{
484482
let dim = shape.dim;
485483
let is_custom = shape.strides.is_custom();
486484
dimension::can_index_slice_with_strides(&v, &dim, &shape.strides, dimension::CanIndexCheckMode::OwnedMutable)?;
@@ -516,16 +514,16 @@ where
516514
/// 5. The strides must not allow any element to be referenced by two different
517515
/// indices.
518516
pub unsafe fn from_shape_vec_unchecked<Sh>(shape: Sh, v: Vec<A>) -> Self
519-
where
520-
Sh: Into<StrideShape<D>>,
517+
where Sh: Into<StrideShape<D>>
521518
{
522519
let shape = shape.into();
523520
let dim = shape.dim;
524521
let strides = shape.strides.strides_for_dim(&dim);
525522
Self::from_vec_dim_stride_unchecked(dim, strides, v)
526523
}
527524

528-
unsafe fn from_vec_dim_stride_unchecked(dim: D, strides: D, mut v: Vec<A>) -> Self {
525+
unsafe fn from_vec_dim_stride_unchecked(dim: D, strides: D, mut v: Vec<A>) -> Self
526+
{
529527
// debug check for issues that indicates wrong use of this constructor
530528
debug_assert!(dimension::can_index_slice(&v, &dim, &strides, CanIndexCheckMode::OwnedMutable).is_ok());
531529

@@ -598,8 +596,7 @@ where
598596
/// # let _ = shift_by_two;
599597
/// ```
600598
pub fn uninit<Sh>(shape: Sh) -> ArrayBase<S::MaybeUninit, D>
601-
where
602-
Sh: ShapeBuilder<Dim = D>,
599+
where Sh: ShapeBuilder<Dim = D>
603600
{
604601
unsafe {
605602
let shape = shape.into_shape_with_order();

src/linspace.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@ use num_traits::Float;
1414
/// An iterator of a sequence of evenly spaced floats.
1515
///
1616
/// Iterator element type is `F`.
17-
pub struct Linspace<F> {
17+
pub struct Linspace<F>
18+
{
1819
start: F,
1920
step: F,
2021
index: usize,
2122
len: usize,
2223
}
2324

2425
impl<F> Iterator for Linspace<F>
25-
where
26-
F: Float,
26+
where F: Float
2727
{
2828
type Item = F;
2929

3030
#[inline]
31-
fn next(&mut self) -> Option<F> {
31+
fn next(&mut self) -> Option<F>
32+
{
3233
if self.index >= self.len {
3334
None
3435
} else {
@@ -40,18 +41,19 @@ where
4041
}
4142

4243
#[inline]
43-
fn size_hint(&self) -> (usize, Option<usize>) {
44+
fn size_hint(&self) -> (usize, Option<usize>)
45+
{
4446
let n = self.len - self.index;
4547
(n, Some(n))
4648
}
4749
}
4850

4951
impl<F> DoubleEndedIterator for Linspace<F>
50-
where
51-
F: Float,
52+
where F: Float
5253
{
5354
#[inline]
54-
fn next_back(&mut self) -> Option<F> {
55+
fn next_back(&mut self) -> Option<F>
56+
{
5557
if self.index >= self.len {
5658
None
5759
} else {
@@ -82,12 +84,10 @@ where
8284
F: Float,
8385
{
8486
let (a, b, num_steps) = match (range.start_bound(), range.end_bound()) {
85-
(Bound::Included(a), Bound::Included(b)) => {
86-
(*a, *b, F::from(n - 1).expect("Converting number of steps to `A` must not fail."))
87-
}
88-
(Bound::Included(a), Bound::Excluded(b)) => {
89-
(*a, *b, F::from(n).expect("Converting number of steps to `A` must not fail."))
90-
}
87+
(Bound::Included(a), Bound::Included(b)) =>
88+
(*a, *b, F::from(n - 1).expect("Converting number of steps to `A` must not fail.")),
89+
(Bound::Included(a), Bound::Excluded(b)) =>
90+
(*a, *b, F::from(n).expect("Converting number of steps to `A` must not fail.")),
9191
_ => panic!("Only a..b and a..=b ranges are supported."),
9292
};
9393

@@ -116,8 +116,7 @@ where
116116
/// **Panics** if converting `((b - a) / step).ceil()` to type `F` fails.
117117
#[inline]
118118
pub fn range<F>(a: F, b: F, step: F) -> Linspace<F>
119-
where
120-
F: Float,
119+
where F: Float
121120
{
122121
let len = b - a;
123122
let steps = F::ceil(len / step);

src/logspace.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// except according to those terms.
88
#![cfg(feature = "std")]
99

10-
use std::ops::{Bound, RangeBounds};
1110
use num_traits::Float;
11+
use std::ops::{Bound, RangeBounds};
1212

1313
/// An iterator of a sequence of logarithmically spaced number.
1414
///
@@ -82,17 +82,15 @@ impl<F> ExactSizeIterator for Logspace<F> where Logspace<F>: Iterator {}
8282
/// **Panics** if converting `n - 1` to type `F` fails.
8383
#[inline]
8484
pub fn logspace<R, F>(base: F, range: R, n: usize) -> Logspace<F>
85-
where
85+
where
8686
R: RangeBounds<F>,
8787
F: Float,
8888
{
8989
let (a, b, num_steps) = match (range.start_bound(), range.end_bound()) {
90-
(Bound::Included(a), Bound::Included(b)) => {
91-
(*a, *b, F::from(n - 1).expect("Converting number of steps to `A` must not fail."))
92-
}
93-
(Bound::Included(a), Bound::Excluded(b)) => {
94-
(*a, *b, F::from(n).expect("Converting number of steps to `A` must not fail."))
95-
}
90+
(Bound::Included(a), Bound::Included(b)) =>
91+
(*a, *b, F::from(n - 1).expect("Converting number of steps to `A` must not fail.")),
92+
(Bound::Included(a), Bound::Excluded(b)) =>
93+
(*a, *b, F::from(n).expect("Converting number of steps to `A` must not fail.")),
9694
_ => panic!("Only a..b and a..=b ranges are supported."),
9795
};
9896

0 commit comments

Comments
 (0)