Trait na::scalar::SupersetOf[][src]

pub trait SupersetOf<T> {
    pub fn is_in_subset(&self) -> bool;
pub fn to_subset_unchecked(&self) -> T;
pub fn from_subset(element: &T) -> Self; pub fn to_subset(&self) -> Option<T> { ... } }

Nested sets and conversions between them. Useful to work with substructures. It is preferable to implement the SubsetOf trait instead of SupersetOf whenever possible (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:

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

pub fn is_in_subset(&self) -> bool[src]

Checks if self is actually part of its subset T (and can be converted to it).

pub fn to_subset_unchecked(&self) -> T[src]

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

pub fn from_subset(element: &T) -> Self[src]

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

Loading content...

Provided methods

pub fn to_subset(&self) -> Option<T>[src]

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.

Loading content...

Implementors

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[src]

Loading content...