Stack

Struct Stack 

Source
pub struct Stack<T, const N: usize = 128> { /* private fields */ }
Expand description

Bounded-capacity stack with const fn operations. Used to store syntax spans via Syntax type alias.

Implementations§

Source§

impl<T, const N: usize> Stack<T, N>

Source

pub const fn as_slice(&self) -> &[T]

Returns the underlying slice of elements.

Source

pub fn iter( &self, ) -> impl ExactSizeIterator<Item = &T> + DoubleEndedIterator + '_

Iterates over elements in this stack in the order of their insertion.

Source

pub const fn is_empty(&self) -> bool

Checks whether the stack is empty (has 0 elements).

Source

pub const fn len(&self) -> usize

Returns the number of elements in the stack.

Trait Implementations§

Source§

impl<T, const N: usize> AsRef<[T]> for Stack<T, N>

Source§

fn as_ref(&self) -> &[T]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Debug, const N: usize> Debug for Stack<T, N>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T, const N: usize> IntoIterator for &'a Stack<T, N>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: PartialEq, const N: usize> PartialEq for Stack<T, N>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for Stack<T, N>
where T: Freeze,

§

impl<T, const N: usize> RefUnwindSafe for Stack<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> Send for Stack<T, N>
where T: Send,

§

impl<T, const N: usize> Sync for Stack<T, N>
where T: Sync,

§

impl<T, const N: usize> Unpin for Stack<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnwindSafe for Stack<T, N>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.