pub(crate) struct ConstLengthsStack<const K: usize> {
data: [Option<BranchMeta>; K],
idx: usize,
}
Expand description
A data structure that holds up to K BranchMeta
items.
Note: It should be possible to store the required data in the builder buffer itself, which would eliminate the need for this helper struct and the limit it imposes.
Fields§
§data: [Option<BranchMeta>; K]
§idx: usize
Implementations§
source§impl<const K: usize> ConstLengthsStack<K>
impl<const K: usize> ConstLengthsStack<K>
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new empty ConstLengthsStack
.
sourcepub const fn push_or_panic(self, meta: BranchMeta) -> Self
pub const fn push_or_panic(self, meta: BranchMeta) -> Self
Adds a BranchMeta
to the stack, panicking if there is no room.
sourcepub const fn peek_or_panic(&self) -> BranchMeta
pub const fn peek_or_panic(&self) -> BranchMeta
Returns a copy of the BranchMeta
on the top of the stack, panicking if
the stack is empty.
sourceconst fn get_or_panic(&self, index: usize) -> BranchMeta
const fn get_or_panic(&self, index: usize) -> BranchMeta
Returns a copy of the BranchMeta
at the specified index.
sourcepub const fn pop_many_or_panic(
self,
len: usize,
) -> (Self, ConstArrayBuilder<256, BranchMeta>)
pub const fn pop_many_or_panic( self, len: usize, ) -> (Self, ConstArrayBuilder<256, BranchMeta>)
Removes many BranchMeta
s from the stack, returning them in a ConstArrayBuilder
.
sourcefn as_slice(&self) -> &[Option<BranchMeta>]
fn as_slice(&self) -> &[Option<BranchMeta>]
Non-const function that returns the initialized elements as a slice.
Trait Implementations§
Auto Trait Implementations§
impl<const K: usize> Freeze for ConstLengthsStack<K>
impl<const K: usize> RefUnwindSafe for ConstLengthsStack<K>
impl<const K: usize> Send for ConstLengthsStack<K>
impl<const K: usize> Sync for ConstLengthsStack<K>
impl<const K: usize> Unpin for ConstLengthsStack<K>
impl<const K: usize> UnwindSafe for ConstLengthsStack<K>
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