Struct DynStack
pub struct DynStack<'a> {
pub(crate) buffer: &'a mut [MaybeUninit<u8>],
}
Expand description
Stack wrapper around a buffer of uninitialized bytes.
Fields§
§buffer: &'a mut [MaybeUninit<u8>]
Implementations§
§impl<'a> DynStack<'a>
impl<'a> DynStack<'a>
pub fn new(buffer: &'a mut [MaybeUninit<u8>]) -> DynStack<'a>
pub fn new(buffer: &'a mut [MaybeUninit<u8>]) -> DynStack<'a>
Returns a new DynStack
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_uninit<T>(
self,
size: usize,
align: usize,
) -> (DynArray<'a, MaybeUninit<T>>, DynStack<'a>)
pub fn make_aligned_uninit<T>( self, size: usize, align: usize, ) -> (DynArray<'a, MaybeUninit<T>>, DynStack<'a>)
pub fn make_aligned_with<T, F>(
self,
size: usize,
align: usize,
f: F,
) -> (DynArray<'a, T>, DynStack<'a>)
pub fn make_aligned_with<T, F>( self, size: usize, align: usize, f: F, ) -> (DynArray<'a, T>, DynStack<'a>)
pub fn make_uninit<T>(
self,
size: usize,
) -> (DynArray<'a, MaybeUninit<T>>, DynStack<'a>)
pub fn make_uninit<T>( self, size: usize, ) -> (DynArray<'a, MaybeUninit<T>>, DynStack<'a>)
pub fn collect_aligned<I>(
self,
align: usize,
iter: I,
) -> (DynArray<'a, <I as IntoIterator>::Item>, DynStack<'a>)where
I: IntoIterator,
pub fn collect_aligned<I>(
self,
align: usize,
iter: I,
) -> (DynArray<'a, <I as IntoIterator>::Item>, DynStack<'a>)where
I: IntoIterator,
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.
pub fn collect<I>(
self,
iter: I,
) -> (DynArray<'a, <I as IntoIterator>::Item>, DynStack<'a>)where
I: IntoIterator,
pub fn collect<I>(
self,
iter: I,
) -> (DynArray<'a, <I as IntoIterator>::Item>, DynStack<'a>)where
I: IntoIterator,
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for DynStack<'a>
impl<'a> RefUnwindSafe for DynStack<'a>
impl<'a> Send for DynStack<'a>
impl<'a> Sync for DynStack<'a>
impl<'a> Unpin for DynStack<'a>
impl<'a> !UnwindSafe for DynStack<'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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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