Trait ndarray::AsArray

source ·
pub trait AsArray<'a, A: 'a, D = Ix1>: Into<ArrayView<'a, A, D>>where
    D: Dimension,{ }
Expand description

Argument conversion into an array view

The trait is parameterized over A, the element type, and D, the dimensionality of the array. D defaults to one-dimensional.

Use .into() to do the conversion.

use ndarray::AsArray;

fn sum<'a, V: AsArray<'a, f64>>(data: V) -> f64 {
    let array_view = data.into();
    array_view.sum()
}

assert_eq!(
    sum(&[1., 2., 3.]),
    6.
);

Implementors§

source§

impl<'a, A: 'a, D, T> AsArray<'a, A, D> for Twhere T: Into<ArrayView<'a, A, D>>, D: Dimension,