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