Struct Storage

Source
pub struct Storage<'a, BackingTy> { /* private fields */ }
Expand description

A wrapper over the innards of a FlatVec which exposes mutating operations which cannot corrupt other elements when inserting a new element.

Implementations§

Source§

impl<BackingTy> Storage<'_, BackingTy>
where BackingTy: Default,

Source

pub fn allocate(&mut self, requested: usize) -> &mut [BackingTy]

Returns a Default slice of BackingTy that will be considered part of this flattened object.

Note that even if you do not use part of this slice, the whole slice will be presented to a FromFlat implementation. This function may be called multiple times in a single IntoFlat implementation or combined with Storage::extend if a flattened object is complex, but it is significantly more efficient to use a single Storage::allocate call where possible.

Source

pub fn reserve(&mut self, requested: usize)

Reserves capacity for at least len additional BackingTy.

Source

pub fn extend<Iter>(&mut self, iter: Iter)
where Iter: IntoIterator<Item = BackingTy>,

Inserts the BackingTy yielded by iter.

In general, this is ~2x slower than calling allocate when the exact size of the inserted object is known.

Auto Trait Implementations§

§

impl<'a, BackingTy> Freeze for Storage<'a, BackingTy>

§

impl<'a, BackingTy> RefUnwindSafe for Storage<'a, BackingTy>
where BackingTy: RefUnwindSafe,

§

impl<'a, BackingTy> Send for Storage<'a, BackingTy>
where BackingTy: Send,

§

impl<'a, BackingTy> Sync for Storage<'a, BackingTy>
where BackingTy: Sync,

§

impl<'a, BackingTy> Unpin for Storage<'a, BackingTy>

§

impl<'a, BackingTy> !UnwindSafe for Storage<'a, BackingTy>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.