@@ -44,7 +44,8 @@ use rawpointer::PointerExt;
4444///
4545/// ## Constructor methods for one-dimensional arrays.
4646impl < S , A > ArrayBase < S , Ix1 >
47- where S : DataOwned < Elem = A >
47+ where
48+ S : DataOwned < Elem = A > ,
4849{
4950 /// Create a one-dimensional array from a vector (no copying needed).
5051 ///
@@ -55,13 +56,9 @@ where S: DataOwned<Elem = A>
5556 ///
5657 /// let array = Array::from_vec(vec![1., 2., 3., 4.]);
5758 /// ```
58- pub fn from_vec ( v : Vec < A > ) -> Self
59- {
59+ pub fn from_vec ( v : Vec < A > ) -> Self {
6060 if mem:: size_of :: < A > ( ) == 0 {
61- assert ! (
62- v. len( ) <= isize :: MAX as usize ,
63- "Length must fit in `isize`." ,
64- ) ;
61+ assert ! ( v. len( ) <= isize :: MAX as usize , "Length must fit in `isize`." , ) ;
6562 }
6663 unsafe { Self :: from_shape_vec_unchecked ( v. len ( ) as Ix , v) }
6764 }
@@ -76,8 +73,7 @@ where S: DataOwned<Elem = A>
7673 /// let array = Array::from_iter(0..10);
7774 /// ```
7875 #[ allow( clippy:: should_implement_trait) ]
79- pub fn from_iter < I : IntoIterator < Item = A > > ( iterable : I ) -> Self
80- {
76+ pub fn from_iter < I : IntoIterator < Item = A > > ( iterable : I ) -> Self {
8177 Self :: from_vec ( iterable. into_iter ( ) . collect ( ) )
8278 }
8379
@@ -99,10 +95,12 @@ where S: DataOwned<Elem = A>
9995 /// assert!(array == arr1(&[0.0, 0.25, 0.5, 0.75, 1.0]))
10096 /// ```
10197 #[ cfg( feature = "std" ) ]
102- pub fn linspace ( start : A , end : A , n : usize ) -> Self
103- where A : Float
98+ pub fn linspace < R > ( range : R , n : usize ) -> Self
99+ where
100+ R : std:: ops:: RangeBounds < A > ,
101+ A : Float ,
104102 {
105- Self :: from ( to_vec ( linspace:: linspace ( start , end , n) ) )
103+ Self :: from ( to_vec ( linspace:: linspace ( range , n) ) )
106104 }
107105
108106 /// Create a one-dimensional array with elements from `start` to `end`
@@ -118,7 +116,8 @@ where S: DataOwned<Elem = A>
118116 /// ```
119117 #[ cfg( feature = "std" ) ]
120118 pub fn range ( start : A , end : A , step : A ) -> Self
121- where A : Float
119+ where
120+ A : Float ,
122121 {
123122 Self :: from ( to_vec ( linspace:: range ( start, end, step) ) )
124123 }
@@ -145,10 +144,12 @@ where S: DataOwned<Elem = A>
145144 /// # }
146145 /// ```
147146 #[ cfg( feature = "std" ) ]
148- pub fn logspace ( base : A , start : A , end : A , n : usize ) -> Self
149- where A : Float
147+ pub fn logspace < R > ( base : A , range : R , n : usize ) -> Self
148+ where
149+ R : std:: ops:: RangeBounds < A > ,
150+ A : Float ,
150151 {
151- Self :: from ( to_vec ( logspace:: logspace ( base, start , end , n) ) )
152+ Self :: from ( to_vec ( logspace:: logspace ( base, range , n) ) )
152153 }
153154
154155 /// Create a one-dimensional array with `n` geometrically spaced elements
@@ -180,15 +181,17 @@ where S: DataOwned<Elem = A>
180181 /// ```
181182 #[ cfg( feature = "std" ) ]
182183 pub fn geomspace ( start : A , end : A , n : usize ) -> Option < Self >
183- where A : Float
184+ where
185+ A : Float ,
184186 {
185187 Some ( Self :: from ( to_vec ( geomspace:: geomspace ( start, end, n) ?) ) )
186188 }
187189}
188190
189191/// ## Constructor methods for two-dimensional arrays.
190192impl < S , A > ArrayBase < S , Ix2 >
191- where S : DataOwned < Elem = A >
193+ where
194+ S : DataOwned < Elem = A > ,
192195{
193196 /// Create an identity matrix of size `n` (square 2D array).
194197 ///
@@ -470,14 +473,14 @@ where
470473 /// );
471474 /// ```
472475 pub fn from_shape_vec < Sh > ( shape : Sh , v : Vec < A > ) -> Result < Self , ShapeError >
473- where Sh : Into < StrideShape < D > >
476+ where
477+ Sh : Into < StrideShape < D > > ,
474478 {
475479 // eliminate the type parameter Sh as soon as possible
476480 Self :: from_shape_vec_impl ( shape. into ( ) , v)
477481 }
478482
479- fn from_shape_vec_impl ( shape : StrideShape < D > , v : Vec < A > ) -> Result < Self , ShapeError >
480- {
483+ fn from_shape_vec_impl ( shape : StrideShape < D > , v : Vec < A > ) -> Result < Self , ShapeError > {
481484 let dim = shape. dim ;
482485 let is_custom = shape. strides . is_custom ( ) ;
483486 dimension:: can_index_slice_with_strides ( & v, & dim, & shape. strides , dimension:: CanIndexCheckMode :: OwnedMutable ) ?;
@@ -513,16 +516,16 @@ where
513516 /// 5. The strides must not allow any element to be referenced by two different
514517 /// indices.
515518 pub unsafe fn from_shape_vec_unchecked < Sh > ( shape : Sh , v : Vec < A > ) -> Self
516- where Sh : Into < StrideShape < D > >
519+ where
520+ Sh : Into < StrideShape < D > > ,
517521 {
518522 let shape = shape. into ( ) ;
519523 let dim = shape. dim ;
520524 let strides = shape. strides . strides_for_dim ( & dim) ;
521525 Self :: from_vec_dim_stride_unchecked ( dim, strides, v)
522526 }
523527
524- unsafe fn from_vec_dim_stride_unchecked ( dim : D , strides : D , mut v : Vec < A > ) -> Self
525- {
528+ unsafe fn from_vec_dim_stride_unchecked ( dim : D , strides : D , mut v : Vec < A > ) -> Self {
526529 // debug check for issues that indicates wrong use of this constructor
527530 debug_assert ! ( dimension:: can_index_slice( & v, & dim, & strides, CanIndexCheckMode :: OwnedMutable ) . is_ok( ) ) ;
528531
@@ -595,7 +598,8 @@ where
595598 /// # let _ = shift_by_two;
596599 /// ```
597600 pub fn uninit < Sh > ( shape : Sh ) -> ArrayBase < S :: MaybeUninit , D >
598- where Sh : ShapeBuilder < Dim = D >
601+ where
602+ Sh : ShapeBuilder < Dim = D > ,
599603 {
600604 unsafe {
601605 let shape = shape. into_shape_with_order ( ) ;
0 commit comments