Trait rubbl_core::num::DimFromShapeSlice [−][src]
pub trait DimFromShapeSlice<T>: Sized {
fn from_shape_slice(shape: &[T]) -> Result<Self, DimensionMismatchError>;
}
Expand description
Adapt a slice representing an array shape into an ndarray::Dimension
type.
In ndarray
array dimensionalities are statically typed, but it is often
the case that we are reading arrays from data files where the array
dimensionality may not match the expectations of the compiled code. This
trait makes it possible to convert a runtime-flexible array shape into one
of the compile-time types … if the two dimensionalities are in fact the
same.
Required methods
fn from_shape_slice(shape: &[T]) -> Result<Self, DimensionMismatchError>
fn from_shape_slice(shape: &[T]) -> Result<Self, DimensionMismatchError>
Try to create the implementing type from the specified array shape, specified as a slice.
Returns an Err with an ErrorKind of DimensionMismatch if the slice size does not match the expected dimensionality.