pub struct PodStack<'a> { /* private fields */ }
Expand description
Stack wrapper around a buffer of bytes.
Implementations§
source§impl<'a> PodStack<'a>
impl<'a> PodStack<'a>
sourcepub fn new(buffer: &'a mut [u8]) -> Self
pub fn new(buffer: &'a mut [u8]) -> Self
Returns a new PodStack
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 make_aligned_with<T: Pod, F: FnMut(usize) -> T>(
self,
size: usize,
align: usize,
f: F
) -> (DynArray<'a, T>, Self)
pub fn make_aligned_with<T: Pod, F: FnMut(usize) -> T>( self, size: usize, align: usize, f: F ) -> (DynArray<'a, T>, Self)
sourcepub fn make_with<T: Pod, F: FnMut(usize) -> T>(
self,
size: usize,
f: F
) -> (DynArray<'a, T>, Self)
pub fn make_with<T: Pod, 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)where
I::Item: Pod,
pub fn collect_aligned<I: IntoIterator>( self, align: usize, iter: I ) -> (DynArray<'a, I::Item>, Self)where I::Item: Pod,
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.