Struct PodStack
pub struct PodStack<'a> {
pub(crate) buffer: &'a mut [u8],
}
Expand description
Stack wrapper around a buffer of bytes.
Fields§
§buffer: &'a mut [u8]
Implementations§
§impl<'a> PodStack<'a>
impl<'a> PodStack<'a>
pub fn new(buffer: &'a mut [u8]) -> PodStack<'a>
pub fn new(buffer: &'a mut [u8]) -> PodStack<'a>
Returns a new PodStack
from the provided memory buffer.
pub 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.
pub fn make_aligned_raw<T>(
self,
size: usize,
align: usize,
) -> (&'a mut [T], PodStack<'a>)where
T: Pod,
pub fn make_aligned_raw<T>(
self,
size: usize,
align: usize,
) -> (&'a mut [T], PodStack<'a>)where
T: Pod,
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.
pub fn make_aligned_with<T, F>(
self,
size: usize,
align: usize,
f: F,
) -> (&'a mut [T], PodStack<'a>)
pub fn make_aligned_with<T, F>( self, size: usize, align: usize, f: F, ) -> (&'a mut [T], PodStack<'a>)
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.
pub fn make_raw<T>(self, size: usize) -> (&'a mut [T], PodStack<'a>)where
T: Pod,
pub fn make_raw<T>(self, size: usize) -> (&'a mut [T], PodStack<'a>)where
T: Pod,
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.
pub fn make_with<T, F>(self, size: usize, f: F) -> (&'a mut [T], PodStack<'a>)
pub fn make_with<T, F>(self, size: usize, f: F) -> (&'a mut [T], PodStack<'a>)
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.
pub fn collect_aligned<I>(
self,
align: usize,
iter: I,
) -> (&'a mut [<I as IntoIterator>::Item], PodStack<'a>)
pub fn collect_aligned<I>( self, align: usize, iter: I, ) -> (&'a mut [<I as IntoIterator>::Item], PodStack<'a>)
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.
pub fn collect<I>(
self,
iter: I,
) -> (&'a mut [<I as IntoIterator>::Item], PodStack<'a>)
pub fn collect<I>( self, iter: I, ) -> (&'a mut [<I as IntoIterator>::Item], PodStack<'a>)
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.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for PodStack<'a>
impl<'a> RefUnwindSafe for PodStack<'a>
impl<'a> Send for PodStack<'a>
impl<'a> Sync for PodStack<'a>
impl<'a> Unpin for PodStack<'a>
impl<'a> !UnwindSafe for PodStack<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more