Function ndarray::aview_mut1[][src]

pub fn aview_mut1<A>(xs: &mut [A]) -> ArrayViewMut1<'_, A>
Expand description

Create a one-dimensional read-write array view with elements borrowing xs.

#[macro_use(s)]
extern crate ndarray;

use ndarray::aview_mut1;

// Create an array view over some data, then slice it and modify it.
fn main() {
    let mut data = [0; 1024];
    {
        let mut a = aview_mut1(&mut data).into_shape((32, 32)).unwrap();
        a.slice_mut(s![.., ..;3]).fill(5);
    }
    assert_eq!(&data[..10], [5, 0, 0, 5, 0, 0, 5, 0, 0, 5]);
}