pub trait Storage {
type Container<T>;
// Required methods
fn new<T>(t: T) -> Self::Container<T>;
fn into_inner<T>(container: Self::Container<T>) -> T;
fn as_ref<T>(container: &Self::Container<T>) -> &T;
fn as_mut<T>(container: &mut Self::Container<T>) -> &mut T;
fn clone<T>(container: &Self::Container<T>) -> Self::Container<T>
where T: Clone;
}Expand description
Generic data storage mechanism.
Currently an abstraction over Box storage (much more memory-efficient)
and inlined structs (sometimes faster).
The particular structure of the trait (GAT for container type) is needed to
enable the storage type to not carry a parameter, e.g. Node<T, InlineStorage> (rather than Node<T, InlineStorage<T>>). This is desirable
to make type inference and trait derivation much more straightforward.
Required Associated Types§
Required Methods§
Sourcefn into_inner<T>(container: Self::Container<T>) -> T
fn into_inner<T>(container: Self::Container<T>) -> T
Destruct the container to retrieve the contained value.
Sourcefn as_ref<T>(container: &Self::Container<T>) -> &T
fn as_ref<T>(container: &Self::Container<T>) -> &T
Retrieve a reference to the contained value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".