Skip to main content

Storage

Trait Storage 

Source
pub trait Storage<T>
where Self: Sized + DerefMut<Target = [T]>,
{ type Error: 'static; const EMPTY: Self; // Required methods fn with_capacity(capacity: usize) -> Result<Self, Self::Error>; fn capacity(&self) -> usize; fn push(&mut self, item: T) -> Result<(), Self::Error>; // Provided method fn reserve(&mut self, additional: usize) -> Result<(), Self::Error> { ... } }
Expand description

Storage being used in a tree.

Required Associated Constants§

Source

const EMPTY: Self

Empty storage.

Required Associated Types§

Source

type Error: 'static

A storage error.

Required Methods§

Source

fn with_capacity(capacity: usize) -> Result<Self, Self::Error>

Construct storage with the given capacity.

Fixed-capacity storage should error if capacity doesn’t fit.

Source

fn capacity(&self) -> usize

Get the capacity of the underlying storage.

Source

fn push(&mut self, item: T) -> Result<(), Self::Error>

Push an item into storage.

Provided Methods§

Source

fn reserve(&mut self, additional: usize) -> Result<(), Self::Error>

Reserve capacity for at least additional more items.

This is a hint. The default does nothing, fixed-capacity storage may error if additional more items don’t fit.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> Storage<T> for Vec<T>

Available on crate feature alloc only.
Source§

fn with_capacity(capacity: usize) -> Result<Self, Self::Error>

Capacity is a hint, and is ignored if it can’t be allocated.

Source§

fn reserve(&mut self, additional: usize) -> Result<(), Self::Error>

Capacity is a hint, and is ignored if it can’t be allocated.

Source§

const EMPTY: Self

Source§

type Error = !

Source§

fn capacity(&self) -> usize

Source§

fn push(&mut self, item: T) -> Result<(), Self::Error>

Implementors§

Source§

impl<T> Storage<T> for EmptyVec<T>

Source§

const EMPTY: Self

Source§

type Error = !