pub trait Wrapper: RawWrapper {
// Required methods
fn new(value: Self::Item) -> Self;
fn value(self) -> Self::Item;
fn get(&self) -> &Self::Item;
fn get_mut(&mut self) -> &mut Self::Item;
// Provided methods
fn replace(&mut self, value: Self::Item) -> Self::Item { ... }
fn set(&mut self, value: Self::Item) -> &mut Self { ... }
fn swap(&mut self, other: &mut Self) { ... }
fn take(&mut self) -> Self::Item
where 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§
Provided Methods§
Sourcefn replace(&mut self, value: Self::Item) -> Self::Item
fn replace(&mut self, value: Self::Item) -> Self::Item
replace replaces the value inside the wrapper with a new one,
returning the old 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.