Struct Queue

Source
pub struct Queue<'a, T> { /* private fields */ }
Expand description

Bounded FIFO queue of T.

Implementations§

Source§

impl<T> Queue<'_, T>

Source

pub fn new<'a>( allocator: &'a LinearAllocator<'_>, capacity: usize, ) -> Option<Queue<'a, T>>

Allocates room for capacity of T and creates a Queue using it.

Source

pub fn from_mut(buffer: &mut [MaybeUninit<T>]) -> Option<Queue<'_, T>>

Creates a Queue using the given backing memory.

Source

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

Pushes value to the back of the queue, returning it back if there’s no room.

Source

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

Removes and returns the value at the front of the queue, or None if the queue is empty.

Source

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

Returns a borrow of the value at the front of the queue without removing it, or None if the queue is empty.

Source

pub fn spare_capacity(&self) -> usize

The amount of elements that could be pushed before the array is full.

Source

pub fn is_full(&self) -> bool

Returns true if there’s no more capacity for additional elements.

Source

pub fn is_empty(&self) -> bool

Returns true if there’s no elements in the queue.

Source

pub fn iter(&self) -> impl Iterator<Item = &T>

Returns an iterator of the elements currently in the queue.

Auto Trait Implementations§

§

impl<'a, T> Freeze for Queue<'a, T>

§

impl<'a, T> RefUnwindSafe for Queue<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Queue<'a, T>
where T: Send,

§

impl<'a, T> Sync for Queue<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Queue<'a, T>

§

impl<'a, T> !UnwindSafe for Queue<'a, T>

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.