pub struct Queue<'a, T> { /* private fields */ }
Expand description
Bounded FIFO queue of T
.
Implementations§
Source§impl<T> Queue<'_, T>
impl<T> Queue<'_, T>
Sourcepub fn new<'a>(
allocator: &'a LinearAllocator<'_>,
capacity: usize,
) -> Option<Queue<'a, T>>
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.
Sourcepub fn from_mut(buffer: &mut [MaybeUninit<T>]) -> Option<Queue<'_, T>>
pub fn from_mut(buffer: &mut [MaybeUninit<T>]) -> Option<Queue<'_, T>>
Creates a Queue
using the given backing memory.
Sourcepub fn push_back(&mut self, value: T) -> Result<(), T>
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.
Sourcepub fn pop_front(&mut self) -> Option<T>
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.
Sourcepub fn peek_front(&mut self) -> Option<&mut T>
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.
Sourcepub fn spare_capacity(&self) -> usize
pub fn spare_capacity(&self) -> usize
The amount of elements that could be pushed before the array is full.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more