Skip to main content

FixedQueue

Struct FixedQueue 

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

Fixed-capacity FIFO queue with no heap allocation.

Implementations§

Source§

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

Source

pub const fn new() -> Self

Creates a new empty queue.

Source

pub fn len(&self) -> usize

Returns the number of elements currently stored.

Source

pub fn is_empty(&self) -> bool

Returns whether the queue is empty.

Source

pub fn is_full(&self) -> bool

Returns whether the queue is full.

Source

pub fn get(&self, index: usize) -> Option<&T>

Returns a shared reference to the element at index from the front.

Source

pub fn back(&self) -> Option<&T>

Returns a shared reference to the last element.

Source

pub fn iter(&self) -> FixedQueueIter<'_, T, N>

Returns an iterator from front to back.

Source

pub fn push_back(&mut self, value: T) -> Result<(), T>

Appends an element to the tail of the queue.

Source

pub fn pop_front(&mut self) -> Option<T>

Removes and returns the element at the head of the queue.

Source

pub fn remove_first_where<F>(&mut self, predicate: F) -> Option<T>
where F: FnMut(&T) -> bool,

Removes the first element matching predicate.

Trait Implementations§

Source§

impl<T, const N: usize> Drop for FixedQueue<T, N>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T, const N: usize> UnsafeUnpin for FixedQueue<T, N>
where T: UnsafeUnpin,

§

impl<T, const N: usize> UnwindSafe for FixedQueue<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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
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.