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: usizeImplementations§
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(&mut self, meta: BranchMeta)
pub const fn push_or_panic(&mut self, meta: BranchMeta)
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(
&mut self,
len: usize,
) -> ConstArrayBuilder<256, BranchMeta>
pub const fn pop_many_or_panic( &mut self, len: usize, ) -> ConstArrayBuilder<256, BranchMeta>
Removes many BranchMetas 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> UnsafeUnpin 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