[−][src]Struct reusable_memory::ReusableMemory
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]
&self,
capacity: [NonZeroUsize; 2]
) -> usize
pub fn borrow_mut_two_as<'mem, T, U>(
&'mem mut self,
capacity: [NonZeroUsize; 2]
) -> (ReusableMemoryBorrow<'mem, T>, ReusableMemoryBorrow<'mem, U>)
[src]
&'mem mut self,
capacity: [NonZeroUsize; 2]
) -> (ReusableMemoryBorrow<'mem, T>, ReusableMemoryBorrow<'mem, U>)
pub fn needed_capacity_for_three<T, U, V>(
&self,
capacity: [NonZeroUsize; 3]
) -> usize
[src]
&self,
capacity: [NonZeroUsize; 3]
) -> usize
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]
&'mem mut self,
capacity: [NonZeroUsize; 3]
) -> (ReusableMemoryBorrow<'mem, T>, ReusableMemoryBorrow<'mem, U>, ReusableMemoryBorrow<'mem, V>)
pub fn needed_capacity_for_four<T, U, V, W>(
&self,
capacity: [NonZeroUsize; 4]
) -> usize
[src]
&self,
capacity: [NonZeroUsize; 4]
) -> usize
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]
&'mem mut self,
capacity: [NonZeroUsize; 4]
) -> (ReusableMemoryBorrow<'mem, T>, ReusableMemoryBorrow<'mem, U>, ReusableMemoryBorrow<'mem, V>, ReusableMemoryBorrow<'mem, W>)
pub fn needed_capacity_for_five<T, U, V, W, X>(
&self,
capacity: [NonZeroUsize; 5]
) -> usize
[src]
&self,
capacity: [NonZeroUsize; 5]
) -> usize
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]
&'mem mut self,
capacity: [NonZeroUsize; 5]
) -> (ReusableMemoryBorrow<'mem, T>, ReusableMemoryBorrow<'mem, U>, ReusableMemoryBorrow<'mem, V>, ReusableMemoryBorrow<'mem, W>, ReusableMemoryBorrow<'mem, X>)
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]
&'mem mut self,
capacity: NonZeroUsize
) -> ReusableMemoryBorrow<'mem, T>
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]
fn clone(&self) -> ReusableMemory<B>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<B: Debug> Debug for ReusableMemory<B>
[src]
Auto Trait Implementations
impl<B> RefUnwindSafe for ReusableMemory<B> where
B: RefUnwindSafe,
B: RefUnwindSafe,
impl<B> Send for ReusableMemory<B> where
B: Send,
B: Send,
impl<B> Sync for ReusableMemory<B> where
B: Sync,
B: Sync,
impl<B> Unpin for ReusableMemory<B> where
B: Unpin,
B: Unpin,
impl<B> UnwindSafe for ReusableMemory<B> where
B: UnwindSafe,
B: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,