[][src]Enum jlrs::value::array::Dimensions

pub enum Dimensions {
    // some variants omitted
}

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]

impl Debug for Dimensions[src]

impl Display for Dimensions[src]

impl Into<Dimensions> for usize[src]

impl Into<Dimensions> for ()[src]

impl<'_> Into<Dimensions> for &'_ [usize][src]

impl Into<Dimensions> for (usize,)[src]

impl Into<Dimensions> for (usize, usize)[src]

impl Into<Dimensions> for (usize, usize, usize)[src]

impl Into<Dimensions> for (usize, usize, usize, usize)[src]

impl Into<Dimensions> for (usize, usize, usize, usize, usize)[src]

impl Into<Dimensions> for (usize, usize, usize, usize, usize, usize)[src]

impl Into<Dimensions> for (usize, usize, usize, usize, usize, usize, usize)[src]

impl Into<Dimensions> for (usize, usize, usize, usize, usize, usize, usize, usize)[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.