[][src]Struct reusable_memory::ReusableMemory

pub struct ReusableMemory<B = u8> { /* fields omitted */ }

Reusable memory struct.

This struct keeps previously allocated memory and can mutably reborrow it as a different type on demand.

The generic type B can be used to control the alignment of the base memory, but it must not be zero sized. Using a zero sized B returns an error in constructor.

Methods

impl<B> ReusableMemory<B>[src]

pub fn needed_capacity_for_two<T, U>(
    &self,
    capacity: [NonZeroUsize; 2]
) -> usize
[src]

pub fn borrow_mut_two_as<'mem, T, U>(
    &'mem mut self,
    capacity: [NonZeroUsize; 2]
) -> (ReusableMemoryBorrow<'mem, T>, ReusableMemoryBorrow<'mem, U>)
[src]

pub fn needed_capacity_for_three<T, U, V>(
    &self,
    capacity: [NonZeroUsize; 3]
) -> usize
[src]

pub fn borrow_mut_three_as<'mem, T, U, V>(
    &'mem mut self,
    capacity: [NonZeroUsize; 3]
) -> (ReusableMemoryBorrow<'mem, T>, ReusableMemoryBorrow<'mem, U>, ReusableMemoryBorrow<'mem, V>)
[src]

pub fn needed_capacity_for_four<T, U, V, W>(
    &self,
    capacity: [NonZeroUsize; 4]
) -> usize
[src]

pub fn borrow_mut_four_as<'mem, T, U, V, W>(
    &'mem mut self,
    capacity: [NonZeroUsize; 4]
) -> (ReusableMemoryBorrow<'mem, T>, ReusableMemoryBorrow<'mem, U>, ReusableMemoryBorrow<'mem, V>, ReusableMemoryBorrow<'mem, W>)
[src]

pub fn needed_capacity_for_five<T, U, V, W, X>(
    &self,
    capacity: [NonZeroUsize; 5]
) -> usize
[src]

pub fn borrow_mut_five_as<'mem, T, U, V, W, X>(
    &'mem mut self,
    capacity: [NonZeroUsize; 5]
) -> (ReusableMemoryBorrow<'mem, T>, ReusableMemoryBorrow<'mem, U>, ReusableMemoryBorrow<'mem, V>, ReusableMemoryBorrow<'mem, W>, ReusableMemoryBorrow<'mem, X>)
[src]

pub const unsafe fn new_unchecked() -> Self[src]

Creates new reusable memory without checking the size of B.

Can be used in const context.

Safety

  • std::mem::size_of::<B>() must not be zero.

pub fn new() -> Self[src]

Panics if size_of::<B>() == 0

pub fn with_capacity(len: usize) -> Self[src]

Counted in the capacity of B.

Panics if size_of::<B>() == 0

pub fn needed_capacity_for<T>(&self, count: NonZeroUsize) -> usize[src]

pub fn borrow_mut_as<'mem, T>(
    &'mem mut self,
    capacity: NonZeroUsize
) -> ReusableMemoryBorrow<'mem, T>
[src]

Borrows the reusable memory as a different type.

This borrow is properly aligned and has at least the requested capacity.

Returns an error if size_of::<T>() == 0. Also returns an error when the pointer could not be aligned properly for T.

Trait Implementations

impl<B: Clone> Clone for ReusableMemory<B>[src]

impl<B: Debug> Debug for ReusableMemory<B>[src]

Auto Trait Implementations

impl<B> RefUnwindSafe for ReusableMemory<B> where
    B: RefUnwindSafe

impl<B> Send for ReusableMemory<B> where
    B: Send

impl<B> Sync for ReusableMemory<B> where
    B: Sync

impl<B> Unpin for ReusableMemory<B> where
    B: Unpin

impl<B> UnwindSafe for ReusableMemory<B> where
    B: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.