pub struct DynStack<'a> { /* private fields */ }
Expand description
Stack wrapper around a buffer of uninitialized bytes.
Implementations§
source§impl<'a> DynStack<'a>
impl<'a> DynStack<'a>
sourcepub fn new(buffer: &'a mut [MaybeUninit<u8>]) -> Self
pub fn new(buffer: &'a mut [MaybeUninit<u8>]) -> Self
Returns a new DynStack
from the provided memory buffer.
sourcepub fn can_hold(&self, alloc_req: StackReq) -> bool
pub fn can_hold(&self, alloc_req: StackReq) -> bool
Returns true
if the stack can hold an allocation with the given size and alignment
requirements.
sourcepub fn as_ptr(&self) -> *const u8
pub fn as_ptr(&self) -> *const u8
Returns a pointer to the (possibly uninitialized) stack memory.
sourcepub fn make_aligned_uninit<T>(
self,
size: usize,
align: usize
) -> (DynArray<'a, MaybeUninit<T>>, Self)
pub fn make_aligned_uninit<T>( self, size: usize, align: usize ) -> (DynArray<'a, MaybeUninit<T>>, Self)
sourcepub fn make_aligned_with<T, F: FnMut(usize) -> T>(
self,
size: usize,
align: usize,
f: F
) -> (DynArray<'a, T>, Self)
pub fn make_aligned_with<T, F: FnMut(usize) -> T>( self, size: usize, align: usize, f: F ) -> (DynArray<'a, T>, Self)
sourcepub fn make_uninit<T>(self, size: usize) -> (DynArray<'a, MaybeUninit<T>>, Self)
pub fn make_uninit<T>(self, size: usize) -> (DynArray<'a, MaybeUninit<T>>, Self)
sourcepub fn make_with<T, F: FnMut(usize) -> T>(
self,
size: usize,
f: F
) -> (DynArray<'a, T>, Self)
pub fn make_with<T, F: FnMut(usize) -> T>( self, size: usize, f: F ) -> (DynArray<'a, T>, Self)
sourcepub fn collect_aligned<I: IntoIterator>(
self,
align: usize,
iter: I
) -> (DynArray<'a, I::Item>, Self)
pub fn collect_aligned<I: IntoIterator>( self, align: usize, iter: I ) -> (DynArray<'a, I::Item>, Self)
Returns a new aligned DynArray
, initialized with the provided iterator, and a stack
over the remainder of the buffer.
If there isn’t enough space for all the iterator items, then the returned array only
contains the first elements that fit into the stack.
Panics
Panics if the provided iterator panics.