Skip to main content

IndexStack

Struct IndexStack 

Source
pub struct IndexStack { /* private fields */ }
Expand description

Bounded LIFO stack of u32 values below its capacity.

Implementations§

Source§

impl IndexStack

Source

pub const MAX_CAPACITY: u32

The largest capacity (2^24 - 1 values).

Source

pub fn with_capacity(capacity: u32) -> Self

An empty stack for the values 0..capacity; a capacity above Self::MAX_CAPACITY is reduced to it.

Source

pub fn capacity(&self) -> usize

The number of values the stack can hold (every value is below it).

Source

pub fn push(&self, value: u32) -> Result<(), u32>

Pushes value; returns it back if it is not below the capacity. Never blocks. value must not already be on the stack: pushing it twice corrupts the stack (a cycle that pops repeat, and the entries below it lost). The pool pushes an index once, when its buffer is dropped.

Source

pub fn pop(&self) -> Option<u32>

Pops the most recently pushed value, or None if the stack is empty. Never blocks.

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.