QueueInner

Struct QueueInner 

Source
pub struct QueueInner<T, S: Storage> { /* private fields */ }
Expand description

Base struct for Queue and QueueView, generic over the Storage.

In most cases you should use Queue or QueueView directly. Only use this struct if you want to write code that’s generic over both.

Implementations§

Source§

impl<T, const N: usize> QueueInner<T, OwnedStorage<N>>

Source

pub const fn new() -> Self

Creates an empty queue.

Source§

impl<T, S: Storage> QueueInner<T, S>

Source

pub fn capacity(&self) -> usize

Returns the maximum number of elements the queue can hold.

Source

pub fn as_view(&self) -> &QueueView<T>

Get a reference to the Queue, erasing the N const-generic.

let queue: Queue<u8, 2> = Queue::new();
let view: &QueueView<u8> = queue.as_view();

It is often preferable to do the same through type coerction, since Queue<T, N> implements Unsize<QueueView<T>>:

let queue: Queue<u8, 2> = Queue::new();
let view: &QueueView<u8> = &queue;
Source

pub fn as_mut_view(&mut self) -> &mut QueueView<T>

Get a mutable reference to the Queue, erasing the N const-generic.

let mut queue: Queue<u8, 2> = Queue::new();
let view: &mut QueueView<u8> = queue.as_mut_view();

It is often preferable to do the same through type coerction, since Queue<T, N> implements Unsize<QueueView<T>>:

let mut queue: Queue<u8, 2> = Queue::new();
let view: &mut QueueView<u8> = &mut queue;
Source

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

Returns the item in the front of the queue, or None if the queue is empty.

Source

pub fn enqueue(&self, item: T) -> Result<(), T>

Adds an item to the end of the queue.

Returns back the item if the queue is full.

Trait Implementations§

Source§

impl<T, S: Storage> Drop for QueueInner<T, S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T, S: Storage> Sync for QueueInner<T, S>
where T: Send,

Auto Trait Implementations§

§

impl<T, S> !Freeze for QueueInner<T, S>

§

impl<T, S> !RefUnwindSafe for QueueInner<T, S>

§

impl<T, S> Send for QueueInner<T, S>
where <S as SealedStorage>::Buffer<Cell<T>>: Send,

§

impl<T, S> Unpin for QueueInner<T, S>
where <S as SealedStorage>::Buffer<Cell<T>>: Unpin,

§

impl<T, S> UnwindSafe for QueueInner<T, S>
where <S as SealedStorage>::Buffer<Cell<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.