Trait Wrapper

Source
pub trait Wrapper: RawWrapper {
    // Required methods
    fn from_value(value: Self::Item) -> Self;
    fn into_inner(self) -> Self::Item;
    fn get(&self) -> &Self::Item;
    fn get_mut(&mut self) -> &mut Self::Item;

    // Provided method
    fn new() -> Self
       where Self: Sized,
             Self::Item: Default { ... }
}
Expand description

The Wrapper trait is used to establish a common interface for all simplemented structures that “wrap” a single value. Essentially, any type capable of implementing #[repr(transparent)] can be considered a wrapper.

Required Methods§

Source

fn from_value(value: Self::Item) -> Self

returns a new instance of the wrapper initialized with the given value

Source

fn into_inner(self) -> Self::Item

consumes the wrapper to return the stored value

Source

fn get(&self) -> &Self::Item

returns an immutable reference to the stored value

Source

fn get_mut(&mut self) -> &mut Self::Item

returns a mutable reference to the stored value

Provided Methods§

Source

fn new() -> Self
where Self: Sized, Self::Item: Default,

returns a new instance of the wrapper initialized with the default value

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§