nalgebra::base::dimension

Trait Dim

Source
pub unsafe trait Dim:
    Any
    + Debug
    + Copy
    + PartialEq
    + Send
    + Sync {
    // Required methods
    fn try_to_usize() -> Option<usize>;
    fn value(&self) -> usize;
    fn from_usize(dim: usize) -> Self;

    // Provided method
    fn is<D: Dim>() -> bool { ... }
}
Expand description

Trait implemented by any type that can be used as a dimension. This includes type-level integers and Dyn (for dimensions not known at compile-time).

§Safety

Hoists integers to the type level, including binary operations.

Required Methods§

Source

fn try_to_usize() -> Option<usize>

Gets the compile-time value of Self. Returns None if it is not known, i.e., if Self = Dyn.

Source

fn value(&self) -> usize

Gets the run-time value of self. For type-level integers, this is the same as Self::try_to_usize().unwrap().

Source

fn from_usize(dim: usize) -> Self

Builds an instance of Self from a run-time value. Panics if Self is a type-level integer and dim != Self::try_to_usize().unwrap().

Provided Methods§

Source

fn is<D: Dim>() -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Dim for Dyn

Source§

impl<const T: usize> Dim for Const<T>