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_raw<T: Pod>(
self,
size: usize,
align: usize
) -> (&'a mut [T], Self)
pub fn make_aligned_raw<T: Pod>( self, size: usize, align: usize ) -> (&'a mut [T], Self)
Returns a new aligned and uninitialized slice and a stack over the remainder of the buffer.
Panics
Panics if the stack isn’t large enough to allocate the array.
sourcepub fn make_aligned_with<T: Pod, F: FnMut(usize) -> T>(
self,
size: usize,
align: usize,
f: F
) -> (&'a mut [T], Self)
pub fn make_aligned_with<T: Pod, F: FnMut(usize) -> T>( self, size: usize, align: usize, f: F ) -> (&'a mut [T], Self)
Returns a new aligned slice, initialized with the provided function, and a stack over the remainder of the buffer.
Panics
Panics if the stack isn’t large enough to allocate the array, or if the provided function panics.
sourcepub fn make_raw<T: Pod>(self, size: usize) -> (&'a mut [T], Self)
pub fn make_raw<T: Pod>(self, size: usize) -> (&'a mut [T], Self)
Returns a new uninitialized slice and a stack over the remainder of the buffer.
Panics
Panics if the stack isn’t large enough to allocate the array.
sourcepub fn make_with<T: Pod, F: FnMut(usize) -> T>(
self,
size: usize,
f: F
) -> (&'a mut [T], Self)
pub fn make_with<T: Pod, F: FnMut(usize) -> T>( self, size: usize, f: F ) -> (&'a mut [T], Self)
Returns a new slice, initialized with the provided function, and a stack over the remainder of the buffer.
Panics
Panics if the stack isn’t large enough to allocate the array, or if the provided function panics.
sourcepub fn collect_aligned<I: IntoIterator>(
self,
align: usize,
iter: I
) -> (&'a mut [I::Item], Self)where
I::Item: Pod,
pub fn collect_aligned<I: IntoIterator>( self, align: usize, iter: I ) -> (&'a mut [I::Item], Self)where I::Item: Pod,
Returns a new aligned slice, 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.
sourcepub fn collect<I: IntoIterator>(self, iter: I) -> (&'a mut [I::Item], Self)where
I::Item: Pod,
pub fn collect<I: IntoIterator>(self, iter: I) -> (&'a mut [I::Item], Self)where I::Item: Pod,
Returns a new slice, 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.