simba::scalar

Trait SubsetOf

Source
pub trait SubsetOf<T>: Sized {
    // Required methods
    fn to_superset(&self) -> T;
    fn from_superset_unchecked(element: &T) -> Self;
    fn is_in_subset(element: &T) -> bool;

    // Provided method
    fn from_superset(element: &T) -> Option<Self> { ... }
}
Expand description

Nested sets and conversions between them (using an injective mapping). Useful to work with substructures. In generic code, it is preferable to use SupersetOf as trait bound whenever possible instead of SubsetOf (because SupersetOf is automatically implemented whenever SubsetOf is).

The notion of “nested sets” is very broad and applies to what the types are supposed to represent, independently from their actual implementation details and limitations. For example:

  • f32 and f64 are both supposed to represent reals and are thus considered equal (even if in practice f64 has more elements).
  • u32 and i8 are respectively supposed to represent natural and relative numbers. Thus, u32 is a subset of i8.
  • A quaternion and a 3x3 orthogonal matrix with unit determinant are both sets of rotations. They can thus be considered equal.

In other words, implementation details due to machine limitations are ignored (otherwise we could not even, e.g., convert a u64 to an i64). If considering those limitations are important, other crates allowing you to query the limitations of given types should be used.

Required Methods§

Source

fn to_superset(&self) -> T

The inclusion map: converts self to the equivalent element of its superset.

Source

fn from_superset_unchecked(element: &T) -> Self

Use with care! Same as self.to_superset but without any property checks. Always succeeds.

Source

fn is_in_subset(element: &T) -> bool

Checks if element is actually part of the subset Self (and can be converted to it).

Provided Methods§

Source

fn from_superset(element: &T) -> Option<Self>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset.

Must return None if element has no equivalent in Self.

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.

Implementations on Foreign Types§

Source§

impl SubsetOf<f32> for f32

Source§

impl SubsetOf<f32> for f64

Source§

impl SubsetOf<f32> for i8

Source§

impl SubsetOf<f32> for i16

Source§

impl SubsetOf<f32> for i32

Source§

impl SubsetOf<f32> for i64

Source§

impl SubsetOf<f32> for i128

Source§

impl SubsetOf<f32> for isize

Source§

impl SubsetOf<f32> for u8

Source§

impl SubsetOf<f32> for u16

Source§

impl SubsetOf<f32> for u32

Source§

impl SubsetOf<f32> for u64

Source§

impl SubsetOf<f32> for u128

Source§

impl SubsetOf<f32> for usize

Source§

impl SubsetOf<f64> for f32

Source§

impl SubsetOf<f64> for f64

Source§

impl SubsetOf<f64> for i8

Source§

impl SubsetOf<f64> for i16

Source§

impl SubsetOf<f64> for i32

Source§

impl SubsetOf<f64> for i64

Source§

impl SubsetOf<f64> for i128

Source§

impl SubsetOf<f64> for isize

Source§

impl SubsetOf<f64> for u8

Source§

impl SubsetOf<f64> for u16

Source§

impl SubsetOf<f64> for u32

Source§

impl SubsetOf<f64> for u64

Source§

impl SubsetOf<f64> for u128

Source§

impl SubsetOf<f64> for usize

Source§

impl SubsetOf<i8> for i8

Source§

impl SubsetOf<i8> for i16

Source§

impl SubsetOf<i8> for i32

Source§

impl SubsetOf<i8> for i64

Source§

impl SubsetOf<i8> for i128

Source§

impl SubsetOf<i8> for isize

Source§

impl SubsetOf<i8> for u8

Source§

impl SubsetOf<i8> for u16

Source§

impl SubsetOf<i8> for u32

Source§

impl SubsetOf<i8> for u64

Source§

impl SubsetOf<i8> for u128

Source§

impl SubsetOf<i8> for usize

Source§

impl SubsetOf<i16> for i8

Source§

impl SubsetOf<i16> for i16

Source§

impl SubsetOf<i16> for i32

Source§

impl SubsetOf<i16> for i64

Source§

impl SubsetOf<i16> for i128

Source§

impl SubsetOf<i16> for isize

Source§

impl SubsetOf<i16> for u8

Source§

impl SubsetOf<i16> for u16

Source§

impl SubsetOf<i16> for u32

Source§

impl SubsetOf<i16> for u64

Source§

impl SubsetOf<i16> for u128

Source§

impl SubsetOf<i16> for usize

Source§

impl SubsetOf<i32> for i8

Source§

impl SubsetOf<i32> for i16

Source§

impl SubsetOf<i32> for i32

Source§

impl SubsetOf<i32> for i64

Source§

impl SubsetOf<i32> for i128

Source§

impl SubsetOf<i32> for isize

Source§

impl SubsetOf<i32> for u8

Source§

impl SubsetOf<i32> for u16

Source§

impl SubsetOf<i32> for u32

Source§

impl SubsetOf<i32> for u64

Source§

impl SubsetOf<i32> for u128

Source§

impl SubsetOf<i32> for usize

Source§

impl SubsetOf<i64> for i8

Source§

impl SubsetOf<i64> for i16

Source§

impl SubsetOf<i64> for i32

Source§

impl SubsetOf<i64> for i64

Source§

impl SubsetOf<i64> for i128

Source§

impl SubsetOf<i64> for isize

Source§

impl SubsetOf<i64> for u8

Source§

impl SubsetOf<i64> for u16

Source§

impl SubsetOf<i64> for u32

Source§

impl SubsetOf<i64> for u64

Source§

impl SubsetOf<i64> for u128

Source§

impl SubsetOf<i64> for usize

Source§

impl SubsetOf<i128> for i8

Source§

impl SubsetOf<i128> for i16

Source§

impl SubsetOf<i128> for i32

Source§

impl SubsetOf<i128> for i64

Source§

impl SubsetOf<i128> for i128

Source§

impl SubsetOf<i128> for isize

Source§

impl SubsetOf<i128> for u8

Source§

impl SubsetOf<i128> for u16

Source§

impl SubsetOf<i128> for u32

Source§

impl SubsetOf<i128> for u64

Source§

impl SubsetOf<i128> for u128

Source§

impl SubsetOf<i128> for usize

Source§

impl SubsetOf<isize> for i8

Source§

impl SubsetOf<isize> for i16

Source§

impl SubsetOf<isize> for i32

Source§

impl SubsetOf<isize> for i64

Source§

impl SubsetOf<isize> for i128

Source§

impl SubsetOf<isize> for isize

Source§

impl SubsetOf<isize> for u8

Source§

impl SubsetOf<isize> for u16

Source§

impl SubsetOf<isize> for u32

Source§

impl SubsetOf<isize> for u64

Source§

impl SubsetOf<isize> for u128

Source§

impl SubsetOf<isize> for usize

Source§

impl SubsetOf<u8> for u8

Source§

impl SubsetOf<u8> for u16

Source§

impl SubsetOf<u8> for u32

Source§

impl SubsetOf<u8> for u64

Source§

impl SubsetOf<u8> for u128

Source§

impl SubsetOf<u8> for usize

Source§

impl SubsetOf<u16> for u8

Source§

impl SubsetOf<u16> for u16

Source§

impl SubsetOf<u16> for u32

Source§

impl SubsetOf<u16> for u64

Source§

impl SubsetOf<u16> for u128

Source§

impl SubsetOf<u16> for usize

Source§

impl SubsetOf<u32> for u8

Source§

impl SubsetOf<u32> for u16

Source§

impl SubsetOf<u32> for u32

Source§

impl SubsetOf<u32> for u64

Source§

impl SubsetOf<u32> for u128

Source§

impl SubsetOf<u32> for usize

Source§

impl SubsetOf<u64> for u8

Source§

impl SubsetOf<u64> for u16

Source§

impl SubsetOf<u64> for u32

Source§

impl SubsetOf<u64> for u64

Source§

impl SubsetOf<u64> for u128

Source§

impl SubsetOf<u64> for usize

Source§

impl SubsetOf<u128> for u8

Source§

impl SubsetOf<u128> for u16

Source§

impl SubsetOf<u128> for u32

Source§

impl SubsetOf<u128> for u64

Source§

impl SubsetOf<u128> for u128

Source§

impl SubsetOf<u128> for usize

Source§

impl SubsetOf<usize> for u8

Source§

impl SubsetOf<usize> for u16

Source§

impl SubsetOf<usize> for u32

Source§

impl SubsetOf<usize> for u64

Source§

impl SubsetOf<usize> for u128

Source§

impl SubsetOf<usize> for usize

Source§

impl<N1, N2: SupersetOf<N1>> SubsetOf<Complex<N2>> for Complex<N1>

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for f32

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for f64

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for i8

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for i16

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for i32

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for i64

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for isize

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for u8

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for u16

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for u32

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for u64

Source§

impl<N2> SubsetOf<AutoSimd<N2>> for usize

Source§

impl<N2: Zero + SupersetOf<f32>> SubsetOf<Complex<N2>> for f32

Source§

impl<N2: Zero + SupersetOf<f64>> SubsetOf<Complex<N2>> for f64

Source§

impl<N2: Zero + SupersetOf<i8>> SubsetOf<Complex<N2>> for i8

Source§

impl<N2: Zero + SupersetOf<i16>> SubsetOf<Complex<N2>> for i16

Source§

impl<N2: Zero + SupersetOf<i32>> SubsetOf<Complex<N2>> for i32

Source§

impl<N2: Zero + SupersetOf<i64>> SubsetOf<Complex<N2>> for i64

Source§

impl<N2: Zero + SupersetOf<i128>> SubsetOf<Complex<N2>> for i128

Source§

impl<N2: Zero + SupersetOf<isize>> SubsetOf<Complex<N2>> for isize

Source§

impl<N2: Zero + SupersetOf<u8>> SubsetOf<Complex<N2>> for u8

Source§

impl<N2: Zero + SupersetOf<u16>> SubsetOf<Complex<N2>> for u16

Source§

impl<N2: Zero + SupersetOf<u32>> SubsetOf<Complex<N2>> for u32

Source§

impl<N2: Zero + SupersetOf<u64>> SubsetOf<Complex<N2>> for u64

Source§

impl<N2: Zero + SupersetOf<u128>> SubsetOf<Complex<N2>> for u128

Source§

impl<N2: Zero + SupersetOf<usize>> SubsetOf<Complex<N2>> for usize

Implementors§

Source§

impl SubsetOf<AutoSimd<[f32; 2]>> for AutoSimd<[f32; 2]>

Source§

impl SubsetOf<AutoSimd<[f32; 4]>> for AutoSimd<[f32; 4]>

Source§

impl SubsetOf<AutoSimd<[f32; 8]>> for AutoSimd<[f32; 8]>

Source§

impl SubsetOf<AutoSimd<[f32; 16]>> for AutoSimd<[f32; 16]>

Source§

impl SubsetOf<AutoSimd<[f64; 2]>> for AutoSimd<[f64; 2]>

Source§

impl SubsetOf<AutoSimd<[f64; 4]>> for AutoSimd<[f64; 4]>

Source§

impl SubsetOf<AutoSimd<[f64; 8]>> for AutoSimd<[f64; 8]>

Source§

impl SubsetOf<AutoSimd<[i8; 2]>> for AutoSimd<[i8; 2]>

Source§

impl SubsetOf<AutoSimd<[i8; 4]>> for AutoSimd<[i8; 4]>

Source§

impl SubsetOf<AutoSimd<[i8; 8]>> for AutoSimd<[i8; 8]>

Source§

impl SubsetOf<AutoSimd<[i8; 16]>> for AutoSimd<[i8; 16]>

Source§

impl SubsetOf<AutoSimd<[i8; 32]>> for AutoSimd<[i8; 32]>

Source§

impl SubsetOf<AutoSimd<[i16; 2]>> for AutoSimd<[i16; 2]>

Source§

impl SubsetOf<AutoSimd<[i16; 4]>> for AutoSimd<[i16; 4]>

Source§

impl SubsetOf<AutoSimd<[i16; 8]>> for AutoSimd<[i16; 8]>

Source§

impl SubsetOf<AutoSimd<[i16; 16]>> for AutoSimd<[i16; 16]>

Source§

impl SubsetOf<AutoSimd<[i16; 32]>> for AutoSimd<[i16; 32]>

Source§

impl SubsetOf<AutoSimd<[i32; 2]>> for AutoSimd<[i32; 2]>

Source§

impl SubsetOf<AutoSimd<[i32; 4]>> for AutoSimd<[i32; 4]>

Source§

impl SubsetOf<AutoSimd<[i32; 8]>> for AutoSimd<[i32; 8]>

Source§

impl SubsetOf<AutoSimd<[i32; 16]>> for AutoSimd<[i32; 16]>

Source§

impl SubsetOf<AutoSimd<[i64; 2]>> for AutoSimd<[i64; 2]>

Source§

impl SubsetOf<AutoSimd<[i64; 4]>> for AutoSimd<[i64; 4]>

Source§

impl SubsetOf<AutoSimd<[i64; 8]>> for AutoSimd<[i64; 8]>

Source§

impl SubsetOf<AutoSimd<[i128; 1]>> for AutoSimd<[i128; 1]>

Source§

impl SubsetOf<AutoSimd<[i128; 2]>> for AutoSimd<[i128; 2]>

Source§

impl SubsetOf<AutoSimd<[i128; 4]>> for AutoSimd<[i128; 4]>

Source§

impl SubsetOf<AutoSimd<[isize; 2]>> for AutoSimd<[isize; 2]>

Source§

impl SubsetOf<AutoSimd<[isize; 4]>> for AutoSimd<[isize; 4]>

Source§

impl SubsetOf<AutoSimd<[isize; 8]>> for AutoSimd<[isize; 8]>

Source§

impl SubsetOf<AutoSimd<[u8; 2]>> for AutoSimd<[u8; 2]>

Source§

impl SubsetOf<AutoSimd<[u8; 4]>> for AutoSimd<[u8; 4]>

Source§

impl SubsetOf<AutoSimd<[u8; 8]>> for AutoSimd<[u8; 8]>

Source§

impl SubsetOf<AutoSimd<[u8; 16]>> for AutoSimd<[u8; 16]>

Source§

impl SubsetOf<AutoSimd<[u8; 32]>> for AutoSimd<[u8; 32]>

Source§

impl SubsetOf<AutoSimd<[u16; 2]>> for AutoSimd<[u16; 2]>

Source§

impl SubsetOf<AutoSimd<[u16; 4]>> for AutoSimd<[u16; 4]>

Source§

impl SubsetOf<AutoSimd<[u16; 8]>> for AutoSimd<[u16; 8]>

Source§

impl SubsetOf<AutoSimd<[u16; 16]>> for AutoSimd<[u16; 16]>

Source§

impl SubsetOf<AutoSimd<[u16; 32]>> for AutoSimd<[u16; 32]>

Source§

impl SubsetOf<AutoSimd<[u32; 2]>> for AutoSimd<[u32; 2]>

Source§

impl SubsetOf<AutoSimd<[u32; 4]>> for AutoSimd<[u32; 4]>

Source§

impl SubsetOf<AutoSimd<[u32; 8]>> for AutoSimd<[u32; 8]>

Source§

impl SubsetOf<AutoSimd<[u32; 16]>> for AutoSimd<[u32; 16]>

Source§

impl SubsetOf<AutoSimd<[u64; 2]>> for AutoSimd<[u64; 2]>

Source§

impl SubsetOf<AutoSimd<[u64; 4]>> for AutoSimd<[u64; 4]>

Source§

impl SubsetOf<AutoSimd<[u64; 8]>> for AutoSimd<[u64; 8]>

Source§

impl SubsetOf<AutoSimd<[u128; 1]>> for AutoSimd<[u128; 1]>

Source§

impl SubsetOf<AutoSimd<[u128; 2]>> for AutoSimd<[u128; 2]>

Source§

impl SubsetOf<AutoSimd<[u128; 4]>> for AutoSimd<[u128; 4]>

Source§

impl SubsetOf<AutoSimd<[usize; 2]>> for AutoSimd<[usize; 2]>

Source§

impl SubsetOf<AutoSimd<[usize; 4]>> for AutoSimd<[usize; 4]>

Source§

impl SubsetOf<AutoSimd<[usize; 8]>> for AutoSimd<[usize; 8]>