pub trait ReadableSliceQueue<T> {
// Required methods
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn peek(&self) -> Option<&T>;
fn peek_n(&self, n: usize) -> Result<&[T], &[T]>;
fn pop(&mut self) -> Result<T, ()>;
fn pop_n(&mut self, n: usize) -> Result<Vec<T>, Vec<T>>;
fn pop_into(&mut self, dst: &mut [T]) -> Result<(), usize>;
fn drop_n(&mut self, n: usize) -> Result<(), usize>;
}Required Methods§
Sourcefn len(&self) -> usize
fn len(&self) -> usize
The amount of elements stored
Returns the amount of elements stored in self
Sourcefn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Checks if there are no elements stored
Returns either true if self is empty or false otherwise
Sourcefn peek(&self) -> Option<&T>
fn peek(&self) -> Option<&T>
Take a look at the first element without consuming it
Returns either Some(element_ref) if we have a first element or None otherwise
Sourcefn peek_n(&self, n: usize) -> Result<&[T], &[T]>
fn peek_n(&self, n: usize) -> Result<&[T], &[T]>
Take a look at the first n elements without consuming them
Parameters:
n: The amount of elements to peek at
Returns either Ok(element_refs) if there were n elements avaliable to peek at or
Err(element_refs) if less elements were available
Sourcefn pop(&mut self) -> Result<T, ()>
fn pop(&mut self) -> Result<T, ()>
Consumes the first element and returns it
Returns either Ok(element) if there was an element to consume or Err(())
otherwise
Sourcefn pop_n(&mut self, n: usize) -> Result<Vec<T>, Vec<T>>
fn pop_n(&mut self, n: usize) -> Result<Vec<T>, Vec<T>>
Consumes the first n elements and returns them
Parameters:
n: The amount of elements to consume
Returns either Ok(elements) if there were n elements avaliable to consume or
Err(elements) if less elements were available