pub struct QueueSingle<Front> { /* private fields */ }Expand description
Implementations§
Source§impl<X1> QueueSingle<X1>
impl<X1> QueueSingle<X1>
Sourcepub fn into_tuple(self) -> X1
pub fn into_tuple(self) -> X1
Converts the queue into its flat tuple representation.
§Examples
use orx_meta::queue::*;
let queue = Queue::new(42);
assert_eq!(queue.into_tuple(), 42);
let queue = Queue::new(42).push(true);
assert_eq!(queue.into_tuple(), (42, true));
let queue = Queue::new(42).push(true).push('x').push("foo");
assert_eq!(queue.into_tuple(), (42, true, 'x', "foo"));Sourcepub fn as_tuple(&self) -> &X1
pub fn as_tuple(&self) -> &X1
Returns a flat tuple representation of references to elements in the queue.
§Examples
use orx_meta::queue::*;
let queue = Queue::new(42);
assert_eq!(queue.as_tuple(), &42);
let queue = Queue::new(42).push(true);
assert_eq!(queue.as_tuple(), (&42, &true));
let queue = Queue::new(42).push(true).push('x').push("foo");
assert_eq!(queue.as_tuple(), (&42, &true, &'x', &"foo"));Sourcepub fn as_tuple_mut(&mut self) -> &mut X1
pub fn as_tuple_mut(&mut self) -> &mut X1
Returns a flat tuple representation of mutable references to elements in the queue.
§Examples
use orx_meta::queue::*;
let mut queue = Queue::new(42);
let a = queue.as_tuple_mut();
*a *= 2;
assert_eq!(queue.as_tuple(), &84);
let mut queue = Queue::new(42).push(true);
let (a, b) = queue.as_tuple_mut();
*a *= 2;
*b = false;
assert_eq!(queue.as_tuple(), (&84, &false));
let mut queue = Queue::new(42).push(true).push('x').push("foo");
let (a, b, c, d) = queue.as_tuple_mut();
*a *= 2;
*b = false;
*c = 'y';
*d = "bar";
assert_eq!(queue.as_tuple(), (&84, &false, &'y', &"bar"));Source§impl<F> QueueSingle<F>
impl<F> QueueSingle<F>
Sourcepub fn new(element: F) -> Self
pub fn new(element: F) -> Self
Creates a new statically-typed queue StQueue containing exactly one element.
Alternatively, we can use multiple element queue’s new. This is for convenience to
allows to work with a single queue type while coding.
§Examples
use orx_meta::queue::*;
let queue: QueueSingle<u32> = QueueSingle::new(42);
assert_eq!(queue.len(), 1);
assert_eq!(queue.front(), &42);
// alternatively, we can use `Queue::new`:
let queue: QueueSingle<u32> = Queue::new(42);
assert_eq!(queue.len(), 1);
assert_eq!(queue.front(), &42);Sourcepub fn pop(self) -> F
pub fn pop(self) -> F
Pops and returns the element in the front of this queue.
Since this element contains only one element, there is no remaining queue once the front is popped. Therefore, the return type is only the element rather than a tuple.
§Examples
use orx_meta::queue::*;
let queue: QueueSingle<u32> = QueueSingle::new(42);
let num = queue.pop();
assert_eq!(num, 42);Trait Implementations§
Source§impl<Front: Clone> Clone for QueueSingle<Front>
impl<Front: Clone> Clone for QueueSingle<Front>
Source§fn clone(&self) -> QueueSingle<Front>
fn clone(&self) -> QueueSingle<Front>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Front: Debug> Debug for QueueSingle<Front>
impl<Front: Debug> Debug for QueueSingle<Front>
Source§impl<Front: PartialEq> PartialEq for QueueSingle<Front>
impl<Front: PartialEq> PartialEq for QueueSingle<Front>
Source§impl<F> StQueue for QueueSingle<F>
impl<F> StQueue for QueueSingle<F>
Source§type PushBack<Elem> = Queue<F, QueueSingle<Elem>>
type PushBack<Elem> = Queue<F, QueueSingle<Elem>>
Type of the queue obtained by adding an element of type
Elem to this queue.Source§type Back = QueueSingle<F>
type Back = QueueSingle<F>
Type of the queue that would be obtained by popping the
Front element of the queue.Source§fn push<Elem>(self, element: Elem) -> Self::PushBack<Elem>
fn push<Elem>(self, element: Elem) -> Self::PushBack<Elem>
Pushes the
element and returns the resulting queue. Read moreSource§fn front(&self) -> &Self::Front
fn front(&self) -> &Self::Front
Returns a reference to the element in the front of the queue. Read more
Source§fn front_mut(&mut self) -> &mut Self::Front
fn front_mut(&mut self) -> &mut Self::Front
Returns a mutable reference to the element in the front of the queue. Read more
Source§fn into_front(self) -> Self::Front
fn into_front(self) -> Self::Front
Consumes the queue and returns the element in the front of the queue. Read more
impl<Front: Copy> Copy for QueueSingle<Front>
impl<Front: Eq> Eq for QueueSingle<Front>
impl<Front> StructuralPartialEq for QueueSingle<Front>
Auto Trait Implementations§
impl<Front> Freeze for QueueSingle<Front>where
Front: Freeze,
impl<Front> RefUnwindSafe for QueueSingle<Front>where
Front: RefUnwindSafe,
impl<Front> Send for QueueSingle<Front>where
Front: Send,
impl<Front> Sync for QueueSingle<Front>where
Front: Sync,
impl<Front> Unpin for QueueSingle<Front>where
Front: Unpin,
impl<Front> UnwindSafe for QueueSingle<Front>where
Front: UnwindSafe,
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