Enum jlrs::value::array::Dimensions [−][src]
The dimensions of an n-dimensional array, they represent either the shape of an array or an
index. Functions that need Dimensions
as an input, which is currently limited to just
indexing this data, are generic and accept any type that implements Into<Dimensions>
.
For a single dimension, you can use a usize
value. For 0 up to and including 8 dimensions,
you can use tuples of usize
. In general, you can use slices of usize
:
let _0d: Dimensions = ().into(); let _1d_value: Dimensions = 42.into(); let _1d_tuple: Dimensions = (42,).into(); let _2d: Dimensions = (42, 6).into(); let _nd: Dimensions = [42, 6, 12, 3].as_ref().into();
Implementations
impl Dimensions
[src]
pub fn n_dimensions(&self) -> usize
[src]
Returns the number of dimensions.
pub fn n_elements(&self, dimension: usize) -> usize
[src]
Returns the number of elements of the nth dimension. Indexing starts at 0.
pub fn size(&self) -> usize
[src]
The product of the number of elements of each dimension.
pub fn index_of<D: Into<Dimensions>>(&self, dim_index: D) -> JlrsResult<usize>
[src]
Calculates the linear index of dim_index
corresponding to a multidimensional array of
shape self
. Returns an error if the index is not valid for this shape.
pub fn as_slice(&self) -> &[usize]
[src]
Returns the raw dimensions as a slice.
Trait Implementations
impl Clone for Dimensions
[src]
fn clone(&self) -> Dimensions
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Dimensions
[src]
impl Display for Dimensions
[src]
Auto Trait Implementations
impl RefUnwindSafe for Dimensions
[src]
impl Send for Dimensions
[src]
impl Sync for Dimensions
[src]
impl Unpin for Dimensions
[src]
impl UnwindSafe for Dimensions
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,