Skip to main content

Deque

Struct Deque 

Source
pub struct Deque<T, S: Storage<ArrayLayout<T>>, I: Capacity> { /* private fields */ }
Expand description

A double-ended queue implemented with a ring buffer.

The “default” usage of this type as a queue is to use push_back to add to the queue, and pop_front to remove from it.

Since Deque is a ring buffer, its elements are not necessarily contiguous in memory. If you want to access the elements as a single slice, such as for efficient sorting, you can use make_contiguous. It rotates the Deque so that its elements do not wrap, and returns a mutable slice to the now contiguous element sequence.

Deque is designed to work with any capacity between 2 and usize::max_value() / 2 (inclusive). As such, almost all indexing operations are implemented as storage[(offset + index) % capacity]; you may therefore observe disproportionate performance benefits when the capacity is known at compile time, especially with powers of 2, which allow this expression to be optimized to storage[(offset + index) & (CAPACITY - 1)].

Implementations§

Source§

impl<T, S: Storage<ArrayLayout<T>>, I: Capacity> Deque<T, S, I>

Source

pub fn into_raw_parts(self) -> (S, I, I)

Decomposes a Deque<T, S, I> into its raw parts.

Returns the raw storage type, the front offset and the length of the deque in elements. These are the same arguments in the same order as the arguments to from_raw_parts.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 3];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_front(1);
deque.push_back(2);
let (buf, front, len) = deque.into_raw_parts();
unsafe {
    assert_eq!(buf[2].assume_init(), 1);
    assert_eq!(buf[0].assume_init(), 2);
    // buf[1] is uninitialized
}
Source

pub unsafe fn from_raw_parts(buf: S, front: I, length: I) -> Self

Creates a Deque<T, S, I> directly from its raw parts.

§Safety

Callers must ensure that the first length values after front (modulo buf.capacity()) are initialized, and that front and length are both less than or equal to buf.capacity().

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 3];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_front(1);
deque.push_back(2);

let (buf, front, len) = deque.into_raw_parts();
let deque = unsafe { coca::collections::SliceDeque::from_raw_parts(buf, front, len) };
assert_eq!(deque, &[1, 2]);
Source

pub fn capacity(&self) -> usize

Returns the number of elements the deque can hold.

Source

pub fn len(&self) -> usize

Returns the number of elements currently in the deque.

Source

pub fn is_empty(&self) -> bool

Returns true exactly when the deque contains zero elements.

Source

pub fn is_full(&self) -> bool

Returns true exactly when the deque contains the maximum number of elements.

Source

pub fn contains(&self, x: &T) -> bool
where T: PartialEq,

Returns true if the Deque contains an element equal to the given value.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 3];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(0);
deque.push_back(1);
assert_eq!(deque.contains(&1), true);
assert_eq!(deque.contains(&10), false);
Source

pub fn get(&self, index: I) -> Option<&T>

Returns a reference to the element at the given index, or None if the index is out of bounds.

The element at index 0 is the front of the queue.

Source

pub fn get_mut(&mut self, index: I) -> Option<&mut T>

Returns a mutable reference to the element at the given index, or None if the index is out of bounds.

The element at index 0 is the front of the queue.

Source

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

Returns a reference to the front element, or None if the Deque is empty.

Source

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

Returns a mutable reference to the front element, or None if the Deque is empty.

Source

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

Returns a reference to the back element, or None if the Deque is empty.

Source

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

Returns a mutable reference to the back element, or None if the Deque is empty.

Source

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

Removes the first element and returns it, or None if the Deque is empty.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 3];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(1);
deque.push_back(2);
assert_eq!(deque.pop_front(), Some(1));
assert_eq!(deque.pop_front(), Some(2));
assert_eq!(deque.pop_front(), None);
Source

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

Removes the last element and returns it, or None if the Deque is empty.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 3];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(1);
deque.push_back(3);
assert_eq!(deque.pop_back(), Some(3));
assert_eq!(deque.pop_back(), Some(1));
assert_eq!(deque.pop_back(), None);
Source

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

Prepends an element to the front of the Deque, returning Err(value) if it is already full.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 3];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
assert!(deque.try_push_front(1).is_ok());
assert!(deque.try_push_front(2).is_ok());
assert!(deque.try_push_front(3).is_ok());
assert_eq!(deque.try_push_front(4), Err(4));
Source

pub fn push_front(&mut self, value: T)

Prepends an element to the front of the Deque.

§Panics

Panics if the deque is already at capacity. See try_push_front for a checked variant that never panics.

Source

pub fn force_push_front(&mut self, value: T) -> Option<T>

Prepends an element to the front of the Deque, replacing and returning the back element if the Deque is already full.

§Examples
let mut deque = coca::collections::InlineDeque::<&'static str, 2>::new();
 
assert!(deque.force_push_front("Alice").is_none());
assert!(deque.force_push_front("Bob").is_none());
assert_eq!(deque.force_push_front("Charlie"), Some("Alice"));
 
assert_eq!(deque[0], "Charlie");
assert_eq!(deque[1], "Bob");
Source

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

Appends an element to the back of the Deque, returning Err(value) if it is already full.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 3];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
assert!(deque.try_push_back(1).is_ok());
assert!(deque.try_push_back(2).is_ok());
assert!(deque.try_push_back(3).is_ok());
assert_eq!(deque.try_push_back(4), Err(4));
Source

pub fn push_back(&mut self, value: T)

Appends an element to the back of the Deque.

§Panics

Panics if the deque is already at capacity. See try_push_back for a checked variant that never panics.

Source

pub fn force_push_back(&mut self, value: T) -> Option<T>

Appends an element to the back of the Deque, replacing and returning the front element if the Deque is already full.

§Examples
let mut deque = coca::collections::InlineDeque::<&'static str, 2>::new();
 
assert!(deque.force_push_back("Hello").is_none());
assert!(deque.force_push_back("World").is_none());
assert_eq!(deque.force_push_back("Peace"), Some("Hello"));
 
assert_eq!(deque[0], "World");
assert_eq!(deque[1], "Peace");
Source

pub fn truncate(&mut self, len: I)

Shortens the Deque, keeping the first len elements and dropping the rest.

If len is greater than the deque’s current length, this has no effect.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(5);
deque.push_back(10);
deque.push_back(15);
assert_eq!(deque.as_slices(), (&[5, 10, 15][..], &[][..]));
deque.truncate(1);
assert_eq!(deque.as_slices(), (&[5][..], &[][..]));
Source

pub fn clear(&mut self)

Clears the Deque, dropping all values.

Source

pub fn swap(&mut self, i: I, j: I)

Swaps the elements at indices i and j.

i and j may be equal.

The element at index 0 is the front of the queue.

§Panics

Panics if either index is out of bounds.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(2);
deque.push_back(1);
deque.push_front(3);
deque.swap(0, 2);
assert_eq!(deque, &[1, 2, 3]);
Source

pub fn swap_remove_front(&mut self, index: I) -> Option<T>

Removes an element from anywhere in the Deque and returns it, replacing it with the front element.

This does not preserve ordering, but is O(1).

Returns None if index is out of bounds.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(1);
deque.push_back(2);
deque.push_back(3);
assert_eq!(deque.swap_remove_front(2), Some(3));
assert_eq!(deque, &[2, 1]);
Source

pub fn swap_remove_back(&mut self, index: I) -> Option<T>

Removes an element from anywhere in the Deque and returns it, replacing it with the back element.

This does not preserve ordering, but is O(1).

Returns None if index is out of bounds.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(1);
deque.push_back(2);
deque.push_back(3);
assert_eq!(deque.swap_remove_back(0), Some(1));
assert_eq!(deque, &[3, 2]);
Source

pub fn try_insert(&mut self, index: I, value: T) -> Result<(), T>

Inserts an element at index within the Deque, returning Err(value) if it is full.

Whichever end is closer to the insertion point will be moved to make room, and all elements in between will be shifted to new positions.

The element at index 0 is the front of the queue.

§Panics

Panics if index is greater than the deque’s length.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<char>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<char>::from(&mut backing_region[..]);
deque.push_back('a');
deque.push_back('b');
deque.push_back('c');
assert_eq!(deque, &['a', 'b', 'c']);

assert!(deque.try_insert(1, 'd').is_ok());
assert_eq!(deque, &['a', 'd', 'b', 'c']);
Source

pub fn insert(&mut self, index: I, value: T)

Inserts an element at index within the Deque.

Whichever end is closer to the insertion point will be moved to make room, and all elements in between will be shifted to new positions.

The element at index 0 is the front of the queue.

§Panics

Panics if index is greater than the deque’s length, or if the deque is already at capacity. See try_insert for a checked version.

Source

pub fn remove(&mut self, index: I) -> Option<T>

Removes and returns the element at index from the Deque, or None if index is out of bounds.

Whichever end is closer to the removal point will be moved to fill the gap, and all affected elements will be shifted to new positions.

The element at index 0 is the front of the queue.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(1);
deque.push_back(2);
deque.push_back(3);
assert_eq!(deque.remove(1), Some(2));
assert_eq!(deque, &[1, 3]);
Source

pub fn replace(&mut self, index: I, value: T) -> T

Places an element at position index within the Deque, returning the element previously stored there.

§Panics

Panics if index is greater than or equal to the deque’s length.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(1);
deque.push_back(2);
deque.push_back(4);
assert_eq!(deque.replace(2, 3), 4);
assert_eq!(deque, &[1, 2, 3]);
Source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&T) -> bool,

Retains only the elements specified by the predicate.

In other words, remove all elements e such that f(&e) returns false. This method operates in place, visiting each element exactly once in the original order, and preserves the order of the retained elements.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(1);
deque.push_back(2);
deque.push_back(3);
deque.push_back(4);
deque.retain(|&x| x % 2 == 0);
assert_eq!(deque, &[2, 4]);
Source

pub fn rotate_left(&mut self, mid: I)

Rotates the Deque mid places to the left.

Equivalently,

  • Rotates mid into the first position.
  • Pops the first mid items and pushes them to the end.
  • Rotates len() - mid places to the right.
§Panics

Panics if mid is greater than the deque’s length. Note that mid == len() does not panic and is a no-op rotation.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 16];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
for x in 0..10 { deque.push_back(x); }
for i in 1..10 {
    deque.rotate_left(3);
    assert_eq!(deque.front(), Some(&(i * 3 % 10)));
}
deque.rotate_left(3);
assert_eq!(deque, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
Source

pub fn rotate_right(&mut self, k: I)

Rotates the Deque k places to the right.

Equivalently,

  • Rotates the first item into position k.
  • Pops the last k items and pushes them to the front.
  • Rotates len() - k places to the left.
§Panics

Panics if k is greater than the deque’s length. Note that k == len() does not panic and is a no-op rotation.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 16];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
for x in 0..10 { deque.push_back(x); }
for i in 1..10 {
    deque.rotate_right(3);
    assert_eq!(deque.get(i * 3 % 10), Some(&0));
}
deque.rotate_right(3);
assert_eq!(deque, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
Source

pub fn as_slices(&self) -> (&[T], &[T])

Returns a pair of slices which contain, in order, the contents of the Deque.

If make_contiguous was previously called, all elements of the deque will be in the first slice and the second slice will be empty.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(2);
deque.push_back(1);
deque.push_front(3);
assert_eq!(deque.as_slices(), (&[3][..], &[2, 1][..]));
Source

pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T])

Returns a pair of mutable slices which contain, in order, the contents of the Deque.

If make_contiguous was previously called, all elements of the deque will be in the first slice and the second slice will be empty.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(2);
deque.push_back(1);
deque.push_front(3);
deque.as_mut_slices().0[0] = 1;
deque.as_mut_slices().1[1] = 3;
assert_eq!(deque.as_slices(), (&[1][..], &[2, 3][..]));
Source

pub fn make_contiguous(&mut self) -> &mut [T]

Rearranges the internal storage of the Deque so it is one contiguous slice, which is then returned.

This does not change the order of the inserted elements. As it returns a mutable slice, this can be used to sort or binary search a deque.

Once the internal storage is contiguous, the as_slices and as_mut_slices methods will return the entire contents of the Deque in a single slice.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(2);
deque.push_back(1);
assert_eq!(deque, &[2, 1]);

deque.push_front(3);
assert_eq!(deque, &[3, 2, 1]);
Source

pub fn iter(&self) -> Iter<'_, T, S, I>

Returns a front-to-back iterator.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(5);
deque.push_back(3);
deque.push_back(4);

let mut it = deque.iter();
assert_eq!(it.next(), Some(&5));
assert_eq!(it.next(), Some(&3));
assert_eq!(it.next(), Some(&4));
assert!(it.next().is_none());
Source

pub fn iter_mut(&mut self) -> IterMut<'_, T, S, I>

Returns a front-to-back iterator that returns mutable references.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 4];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.push_back(5);
deque.push_back(3);
deque.push_back(4);
for num in deque.iter_mut() {
    *num = *num - 2;
}
assert_eq!(deque, &[3, 1, 2]);
Source

pub fn range<R: RangeBounds<I>>(&self, range: R) -> Iter<'_, T, S, I>

Creates an iterator that covers the specified range in the Deque.

§Panics

Panics if the starting point is greater than the end point or if the end point is greater than the length of the deque.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 8];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.extend(1..=5);
assert_eq!(deque, &[1, 2, 3, 4, 5]);

let mut it = deque.range(2..4);
assert_eq!(it.next(), Some(&3));
assert_eq!(it.next(), Some(&4));
assert!(it.next().is_none());
Source

pub fn range_mut<R: RangeBounds<I>>(&mut self, range: R) -> IterMut<'_, T, S, I>

Creates a mutable iterator that covers the specified range in the Deque.

§Panics

Panics if the starting point is greater than the end point or if the end point is greater than the length of the deque.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 8];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.extend(1..=5);
assert_eq!(deque, &[1, 2, 3, 4, 5]);

deque.range_mut(2..4).for_each(|x| *x *= 2);
assert_eq!(deque, &[1, 2, 6, 8, 5]);
Source

pub fn drain<R: RangeBounds<I>>(&mut self, range: R) -> Drain<'_, T, S, I>

Creates a draining iterator that removes the specified range in the deque and yields the removed items.

When the iterator is dropped, all elements in the range are removed from the deque, even if the iterator was not fully consumed. If the iterator is not dropped (with core::mem::forget for example), it is unspecified how many elements are removed.

§Panics

Panics if the starting point is greater than the end point or if the end point is greater than the length of the deque.

§Examples
let mut backing_region = [core::mem::MaybeUninit::<i32>::uninit(); 8];
let mut deque = coca::collections::SliceDeque::<i32>::from(&mut backing_region[..]);
deque.extend(1..=5);

let mut drained = deque.drain(2..4);
assert_eq!(drained.next(), Some(3));
assert_eq!(drained.next(), Some(4));
assert!(drained.next().is_none());

drop(drained);
assert_eq!(deque, [1, 2, 5]);

// A full range clears the deque
deque.drain(..);
assert!(deque.is_empty());
Source§

impl<T: Copy, I: Capacity> Deque<T, AllocStorage<ArrayLayout<T>>, I>

Source

pub fn with_capacity(capacity: I) -> Self

Available on crate feature alloc only.

Creates an empty AllocDeque with the specified capacity.

§Panics

Panics if capacity cannot be represented by the a usize.

Source§

impl<T, I: Capacity, const C: usize> Deque<T, [MaybeUninit<T>; C], I>

Source

pub fn new() -> Self

Constructs a new deque backed by an inline array.

§Panics

Panics if C cannot be represented as a value of type I.

§Examples
let deque = coca::collections::InlineDeque::<u32, 7>::new();
assert_eq!(deque.len(), 0);
assert_eq!(deque.capacity(), 7);

Trait Implementations§

Source§

impl<T: Clone, I: Capacity, const C: usize> Clone for Deque<T, [MaybeUninit<T>; C], I>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, S: Storage<ArrayLayout<T>>, I: Capacity> Debug for Deque<T, S, I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, I: Capacity, const C: usize> Default for Deque<T, [MaybeUninit<T>; C], I>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T, S: Storage<ArrayLayout<T>>, I: Capacity> Drop for Deque<T, S, I>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<'a, T: 'a + Clone, S: Storage<ArrayLayout<T>>, I: Capacity> Extend<&'a T> for Deque<T, S, I>

Source§

fn extend<It: IntoIterator<Item = &'a T>>(&mut self, iter: It)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T, S: Storage<ArrayLayout<T>>, I: Capacity> Extend<T> for Deque<T, S, I>

Source§

fn extend<It: IntoIterator<Item = T>>(&mut self, iter: It)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T, S: Storage<ArrayLayout<T>>, I: Capacity> From<S> for Deque<T, S, I>

Source§

fn from(buf: S) -> Self

Converts a contiguous block of memory into an empty deque.

§Panics

This may panic if the index type I cannot represent buf.capacity().

Source§

impl<T, S: Storage<ArrayLayout<T>>, I: Capacity> From<Vec<T, S, I>> for Deque<T, S, I>

Source§

fn from(vec: Vec<T, S, I>) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash, S: Storage<ArrayLayout<T>>, I: Capacity> Hash for Deque<T, S, I>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, S: Storage<ArrayLayout<T>>, I: Capacity> Index<I> for Deque<T, S, I>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: I) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, S: Storage<ArrayLayout<T>>, I: Capacity> IndexMut<I> for Deque<T, S, I>

Source§

fn index_mut(&mut self, index: I) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, T, S: Storage<ArrayLayout<T>>, I: Capacity> IntoIterator for &'a Deque<T, S, I>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T, S, I>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Iter<'a, T, S, I>

Creates an iterator from a value. Read more
Source§

impl<'a, T, S: Storage<ArrayLayout<T>>, I: Capacity> IntoIterator for &'a mut Deque<T, S, I>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, T, S, I>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> IterMut<'a, T, S, I>

Creates an iterator from a value. Read more
Source§

impl<T, S: Storage<ArrayLayout<T>>, I: Capacity> IntoIterator for Deque<T, S, I>

Source§

fn into_iter(self) -> IntoIter<T, S, I>

Converts the Deque into a front-to-back iterator yielding elements by value.

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T, S, I>

Which kind of iterator are we turning this into?
Source§

impl<T: Ord, S: Storage<ArrayLayout<T>>, I: Capacity> Ord for Deque<T, S, I>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<AT, AS, AI, BT, BS, BI> PartialEq<Deque<BT, BS, BI>> for Deque<AT, AS, AI>
where AT: PartialEq<BT>, AS: Storage<ArrayLayout<AT>>, BS: Storage<ArrayLayout<BT>>, AI: Capacity, BI: Capacity,

Source§

fn eq(&self, other: &Deque<BT, BS, BI>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialEq, S: Storage<ArrayLayout<T>>, I: Capacity, R: AsRef<[T]>> PartialEq<R> for Deque<T, S, I>

Source§

fn eq(&self, other: &R) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, AS, AI, BS, BI> PartialOrd<Deque<T, BS, BI>> for Deque<T, AS, AI>
where T: PartialOrd, AS: Storage<ArrayLayout<T>>, BS: Storage<ArrayLayout<T>>, AI: Capacity, BI: Capacity,

Source§

fn partial_cmp(&self, other: &Deque<T, BS, BI>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Eq, S: Storage<ArrayLayout<T>>, I: Capacity> Eq for Deque<T, S, I>

Auto Trait Implementations§

§

impl<T, S, I> Freeze for Deque<T, S, I>
where I: Freeze, S: Freeze,

§

impl<T, S, I> RefUnwindSafe for Deque<T, S, I>

§

impl<T, S, I> Send for Deque<T, S, I>
where I: Send, S: Send, T: Send,

§

impl<T, S, I> Sync for Deque<T, S, I>
where I: Sync, S: Sync, T: Sync,

§

impl<T, S, I> Unpin for Deque<T, S, I>
where I: Unpin, S: Unpin, T: Unpin,

§

impl<T, S, I> UnsafeUnpin for Deque<T, S, I>
where I: UnsafeUnpin, S: UnsafeUnpin,

§

impl<T, S, I> UnwindSafe for Deque<T, S, I>
where I: UnwindSafe, S: UnwindSafe, 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.