@@ -16,23 +16,18 @@ use crate::{dimension, ArcArray1, ArcArray2};
1616/// three dimensions.
1717///
1818/// ```
19- /// extern crate ndarray;
20- ///
2119/// use ndarray::array;
20+ /// let a1 = array![1, 2, 3, 4];
2221///
23- /// fn main() {
24- /// let a1 = array![1, 2, 3, 4];
25- ///
26- /// let a2 = array![[1, 2],
27- /// [3, 4]];
22+ /// let a2 = array![[1, 2],
23+ /// [3, 4]];
2824///
29- /// let a3 = array![[[1, 2], [3, 4]],
30- /// [[5, 6], [7, 8]]];
25+ /// let a3 = array![[[1, 2], [3, 4]],
26+ /// [[5, 6], [7, 8]]];
3127///
32- /// assert_eq!(a1.shape(), &[4]);
33- /// assert_eq!(a2.shape(), &[2, 2]);
34- /// assert_eq!(a3.shape(), &[2, 2, 2]);
35- /// }
28+ /// assert_eq!(a1.shape(), &[4]);
29+ /// assert_eq!(a2.shape(), &[2, 2]);
30+ /// assert_eq!(a3.shape(), &[2, 2, 2]);
3631/// ```
3732///
3833/// This macro uses `vec![]`, and has the same ownership semantics;
@@ -115,19 +110,14 @@ pub fn aview2<A, V: FixedInitializer<Elem = A>>(xs: &[V]) -> ArrayView2<'_, A> {
115110/// Create a one-dimensional read-write array view with elements borrowing `xs`.
116111///
117112/// ```
118- /// extern crate ndarray;
119- ///
120113/// use ndarray::{aview_mut1, s};
121- ///
122114/// // Create an array view over some data, then slice it and modify it.
123- /// fn main() {
124- /// let mut data = [0; 1024];
125- /// {
126- /// let mut a = aview_mut1(&mut data).into_shape((32, 32)).unwrap();
127- /// a.slice_mut(s![.., ..;3]).fill(5);
128- /// }
129- /// assert_eq!(&data[..10], [5, 0, 0, 5, 0, 0, 5, 0, 0, 5]);
115+ /// let mut data = [0; 1024];
116+ /// {
117+ /// let mut a = aview_mut1(&mut data).into_shape((32, 32)).unwrap();
118+ /// a.slice_mut(s![.., ..;3]).fill(5);
130119/// }
120+ /// assert_eq!(&data[..10], [5, 0, 0, 5, 0, 0, 5, 0, 0, 5]);
131121/// ```
132122pub fn aview_mut1 < A > ( xs : & mut [ A ] ) -> ArrayViewMut1 < ' _ , A > {
133123 ArrayViewMut :: from ( xs)
@@ -143,20 +133,18 @@ pub fn aview_mut1<A>(xs: &mut [A]) -> ArrayViewMut1<'_, A> {
143133/// ```
144134/// use ndarray::aview_mut2;
145135///
146- /// fn main() {
147- /// // The inner (nested) array must be of length 1 to 16, but the outer
148- /// // can be of any length.
149- /// let mut data = [[0.; 2]; 128];
150- /// {
151- /// // Make a 128 x 2 mut array view then turn it into 2 x 128
152- /// let mut a = aview_mut2(&mut data).reversed_axes();
153- /// // Make the first row ones and second row minus ones.
154- /// a.row_mut(0).fill(1.);
155- /// a.row_mut(1).fill(-1.);
156- /// }
157- /// // look at the start of the result
158- /// assert_eq!(&data[..3], [[1., -1.], [1., -1.], [1., -1.]]);
136+ /// // The inner (nested) array must be of length 1 to 16, but the outer
137+ /// // can be of any length.
138+ /// let mut data = [[0.; 2]; 128];
139+ /// {
140+ /// // Make a 128 x 2 mut array view then turn it into 2 x 128
141+ /// let mut a = aview_mut2(&mut data).reversed_axes();
142+ /// // Make the first row ones and second row minus ones.
143+ /// a.row_mut(0).fill(1.);
144+ /// a.row_mut(1).fill(-1.);
159145/// }
146+ /// // look at the start of the result
147+ /// assert_eq!(&data[..3], [[1., -1.], [1., -1.], [1., -1.]]);
160148/// ```
161149pub fn aview_mut2 < A , V : FixedInitializer < Elem = A > > ( xs : & mut [ V ] ) -> ArrayViewMut2 < ' _ , A > {
162150 let cols = V :: len ( ) ;
0 commit comments