Storage

Trait Storage 

Source
pub unsafe trait Storage: AsRef<[MaybeUninit<Self::Item>]> + AsMut<[MaybeUninit<Self::Item>]> {
    type Item;

    // Required methods
    fn reserve(&mut self, new_capacity: usize);
    fn try_reserve(&mut self, new_capacity: usize) -> AllocResult;
}
Expand description

A type that can hold Self::Items, and potentially reserve space for more.

§Safety

Other safe types rely on this trait being implemented correctly. See the safety requirements on each function

Required Associated Types§

Source

type Item

The type of item that this storage can contain

Required Methods§

Source

fn reserve(&mut self, new_capacity: usize)

Reserves space for at least new_capacity elements

§Safety

After this call successfully ends, the capacity must be at least new_capacity

§Panic/Abort

Maybe panic or abort if it is impossible to set the capacity to at least new_capacity

Source

fn try_reserve(&mut self, new_capacity: usize) -> AllocResult

Tries to reserve space for at least new_capacity elements

§Safety

If Ok(()) is returned, the capacity must be at least new_capacity

§Errors

If enough space cannot be reserved, returns Err(AllocError)

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.

Implementations on Foreign Types§

Source§

impl<S: ?Sized + Storage> Storage for &mut S

Source§

type Item = <S as Storage>::Item

Source§

fn reserve(&mut self, new_capacity: usize)

Source§

fn try_reserve(&mut self, new_capacity: usize) -> AllocResult

Source§

impl<T> Storage for [MaybeUninit<T>]

Source§

type Item = T

Source§

fn reserve(&mut self, new_capacity: usize)

Source§

fn try_reserve(&mut self, capacity: usize) -> AllocResult

Source§

impl<T, A: Allocator> Storage for Box<[MaybeUninit<T>], A>

Source§

type Item = T

Source§

fn reserve(&mut self, new_capacity: usize)

Source§

fn try_reserve(&mut self, new_capacity: usize) -> AllocResult

Source§

impl<T, const N: usize> Storage for [MaybeUninit<T>; N]

Source§

type Item = T

Source§

fn reserve(&mut self, capacity: usize)

Source§

fn try_reserve(&mut self, capacity: usize) -> AllocResult

Implementors§