pub trait AsArray<'a, A, D = Dim<[usize; 1]>>: Into<ArrayBase<ViewRepr<&'a A>, D>>where
A: 'a,
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.
);
Object Safety§
This trait is not object safe.