Struct arraydeque::ArrayDeque

source ·
pub struct ArrayDeque<T, const CAP: usize, B: Behavior = Saturating> { /* private fields */ }
Expand description

A fixed capacity ring buffer.

It can be stored directly on the stack if needed.

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 the queue. Iterating over ArrayDeque goes front to back.

Implementations§

source§

impl<T, const CAP: usize> ArrayDeque<T, CAP, Saturating>

source

pub fn push_front(&mut self, element: T) -> Result<(), CapacityError<T>>

Add an element to the front of the deque.

Return Ok(()) if the push succeeds, or return Err(CapacityError { *element* }) if the vector is full.

§Examples
// 1 -(+)-> [_, _, _] => [1, _, _] -> Ok(())
// 2 -(+)-> [1, _, _] => [2, 1, _] -> Ok(())
// 3 -(+)-> [2, 1, _] => [3, 2, 1] -> Ok(())
// 4 -(+)-> [3, 2, 1] => [3, 2, 1] -> Err(CapacityError { element: 4 })

use arraydeque::{ArrayDeque, CapacityError};

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();

buf.push_front(1);
buf.push_front(2);
buf.push_front(3);

let overflow = buf.push_front(4);

assert_eq!(overflow, Err(CapacityError { element: 4 }));
assert_eq!(buf.back(), Some(&1));
source

pub fn push_back(&mut self, element: T) -> Result<(), CapacityError<T>>

Add an element to the back of the deque.

Return Ok(()) if the push succeeds, or return Err(CapacityError { *element* }) if the vector is full.

§Examples
// [_, _, _] <-(+)- 1 => [_, _, 1] -> Ok(())
// [_, _, 1] <-(+)- 2 => [_, 1, 2] -> Ok(())
// [_, 1, 2] <-(+)- 3 => [1, 2, 3] -> Ok(())
// [1, 2, 3] <-(+)- 4 => [1, 2, 3] -> Err(CapacityError { element: 4 })

use arraydeque::{ArrayDeque, CapacityError};

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();

buf.push_back(1);
buf.push_back(2);
buf.push_back(3);

let overflow = buf.push_back(4);

assert_eq!(overflow, Err(CapacityError { element: 4 }));
assert_eq!(buf.back(), Some(&3));
source

pub fn insert( &mut self, index: usize, element: T ) -> Result<(), CapacityError<T>>

Inserts an element at index within the ArrayDeque. Whichever end is closer to the insertion point will be moved to make room, and all the affected elements will be moved to new positions.

Return Ok(()) if the push succeeds, or return Err(CapacityError { *element* }) if the vector is full.

Element at index 0 is the front of the queue.

§Panics

Panics if index is greater than ArrayDeque’s length

§Examples
// [_, _, _] <-(#0)- 3 => [3, _, _] -> Ok(())
// [3, _, _] <-(#0)- 1 => [1, 3, _] -> Ok(())
// [1, 3, _] <-(#1)- 2 => [1, 2, 3] -> Ok(())
// [1, 2, 3] <-(#1)- 4 => [1, 2, 3] -> Err(CapacityError { element: 4 })

use arraydeque::{ArrayDeque, CapacityError};

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();

buf.insert(0, 3);
buf.insert(0, 1);
buf.insert(1, 2);

let overflow = buf.insert(1, 4);

assert_eq!(overflow, Err(CapacityError { element: 4 }));
assert_eq!(buf.back(), Some(&3));
source

pub fn extend_front<I>(&mut self, iter: I)
where I: IntoIterator<Item = T>,

Extend deque from front with the contents of an iterator.

Does not extract more items than there is space for. No error occurs if there are more iterator elements.

§Examples
// [9, 8, 7] -(+)-> [_, _, _, _, _, _, _] => [7, 8, 9, _, _, _, _]
// [6, 5, 4] -(+)-> [7, 8, 9, _, _, _, _] => [4, 5, 6, 7, 8, 9, _]
// [3, 2, 1] -(+)-> [4, 5, 6, 7, 8, 9, _] => [3, 4, 5, 6, 7, 8, 9]

use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 7> = ArrayDeque::new();

buf.extend_front([9, 8, 7].into_iter());
buf.extend_front([6, 5, 4].into_iter());

assert_eq!(buf.len(), 6);

// max capacity reached
buf.extend_front([3, 2, 1].into_iter());

assert_eq!(buf.len(), 7);
assert_eq!(buf, [3, 4, 5, 6, 7, 8, 9].into());
source

pub fn extend_back<I>(&mut self, iter: I)
where I: IntoIterator<Item = T>,

Extend deque from back with the contents of an iterator.

Does not extract more items than there is space for. No error occurs if there are more iterator elements.

§Examples
// [_, _, _, _, _, _, _] <-(+)- [1, 2, 3] => [_, _, _, _, 1, 2, 3]
// [_, _, _, _, 1, 2, 3] <-(+)- [4, 5, 6] => [_, 1, 2, 3, 4, 5, 6]
// [_, 1, 2, 3, 4, 5, 6] <-(+)- [7, 8, 9] => [1, 2, 3, 4, 5, 6, 7]

use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 7> = ArrayDeque::new();

buf.extend_back([1, 2, 3].into_iter());
buf.extend_back([4, 5, 6].into_iter());

assert_eq!(buf.len(), 6);

// max capacity reached
buf.extend_back([7, 8, 9].into_iter());

assert_eq!(buf.len(), 7);
assert_eq!(buf, [1, 2, 3, 4, 5, 6, 7].into());
source§

impl<T, const CAP: usize> ArrayDeque<T, CAP, Wrapping>

source

pub fn push_front(&mut self, element: T) -> Option<T>

Add an element to the front of the deque.

Return None if deque still has capacity, or Some(existing) if the deque is full, where existing is the backmost element being kicked out.

§Examples
// 1 -(+)-> [_, _, _] => [1, _, _] -> None
// 2 -(+)-> [1, _, _] => [2, 1, _] -> None
// 3 -(+)-> [2, 1, _] => [3, 2, 1] -> None
// 4 -(+)-> [3, 2, 1] => [4, 3, 2] -> Some(1)

use arraydeque::{ArrayDeque, Wrapping};

let mut buf: ArrayDeque<_, 3, Wrapping> = ArrayDeque::new();

buf.push_front(1);
buf.push_front(2);
buf.push_front(3);

let existing = buf.push_front(4);

assert_eq!(existing, Some(1));
assert_eq!(buf.back(), Some(&2));
source

pub fn push_back(&mut self, element: T) -> Option<T>

Appends an element to the back of a buffer

Return None if deque still has capacity, or Some(existing) if the deque is full, where existing is the frontmost element being kicked out.

§Examples
// [_, _, _] <-(+)- 1 => [_, _, 1] -> None
// [_, _, 1] <-(+)- 2 => [_, 1, 2] -> None
// [_, 1, 2] <-(+)- 3 => [1, 2, 3] -> None
// [1, 2, 3] <-(+)- 4 => [2, 3, 4] -> Some(1)

use arraydeque::{ArrayDeque, Wrapping};

let mut buf: ArrayDeque<_, 3, Wrapping> = ArrayDeque::new();

buf.push_back(1);
buf.push_back(2);
buf.push_back(3);

let existing = buf.push_back(4);

assert_eq!(existing, Some(1));
assert_eq!(buf.back(), Some(&4));
source

pub fn extend_front<I>(&mut self, iter: I)
where I: IntoIterator<Item = T>,

Extend deque from front with the contents of an iterator.

Extracts all items from iterator and kicks out the backmost element if necessary.

§Examples
// [9, 8, 7] -(+)-> [_, _, _, _, _, _, _] => [7, 8, 9, _, _, _, _]
// [6, 5, 4] -(+)-> [7, 8, 9, _, _, _, _] => [4, 5, 6, 7, 8, 9, _]
// [3, 2, 1] -(+)-> [4, 5, 6, 7, 8, 9, _] => [1, 2, 3, 4, 5, 6, 7]

use arraydeque::{ArrayDeque, Wrapping};

let mut buf: ArrayDeque<_, 7, Wrapping> = ArrayDeque::new();

buf.extend_front([9, 8, 7].into_iter());
buf.extend_front([6, 5, 4].into_iter());

assert_eq!(buf.len(), 6);

// max capacity reached
buf.extend_front([3, 2, 1].into_iter());

assert_eq!(buf.len(), 7);
assert_eq!(buf, [1, 2, 3, 4, 5, 6, 7].into());
source

pub fn extend_back<I>(&mut self, iter: I)
where I: IntoIterator<Item = T>,

Extend deque from back with the contents of an iterator.

Extracts all items from iterator and kicks out the frontmost element if necessary.

§Examples
// [_, _, _, _, _, _, _] <-(+)- [1, 2, 3] => [_, _, _, _, 1, 2, 3]
// [_, _, _, _, 1, 2, 3] <-(+)- [4, 5, 6] => [_, 1, 2, 3, 4, 5, 6]
// [_, 1, 2, 3, 4, 5, 6] <-(+)- [7, 8, 9] => [3, 4, 5, 6, 7, 8, 9]

use arraydeque::{ArrayDeque, Wrapping};

let mut buf: ArrayDeque<_, 7, Wrapping> = ArrayDeque::new();

buf.extend_back([1, 2, 3].into_iter());
buf.extend_back([4, 5, 6].into_iter());

assert_eq!(buf.len(), 6);

// max capacity reached
buf.extend_back([7, 8, 9].into_iter());

assert_eq!(buf.len(), 7);
assert_eq!(buf, [3, 4, 5, 6, 7, 8, 9].into());
source§

impl<T, const CAP: usize, B: Behavior> ArrayDeque<T, CAP, B>

source

pub const fn new() -> ArrayDeque<T, CAP, B>

Creates an empty ArrayDeque.

§Examples
use arraydeque::ArrayDeque;

let buf: ArrayDeque<usize, 2> = ArrayDeque::new();
source

pub const fn capacity(&self) -> usize

Return the capacity of the ArrayDeque.

§Examples
use arraydeque::ArrayDeque;

let buf: ArrayDeque<usize, 2> = ArrayDeque::new();

assert_eq!(buf.capacity(), 2);
source

pub fn len(&self) -> usize

Returns the number of elements in the ArrayDeque.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 1> = ArrayDeque::new();

assert_eq!(buf.len(), 0);

buf.push_back(1);

assert_eq!(buf.len(), 1);
source

pub fn is_empty(&self) -> bool

Returns true if the buffer contains no elements

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 1> = ArrayDeque::new();

assert!(buf.is_empty());

buf.push_back(1);

assert!(!buf.is_empty());
source

pub fn as_uninit_slice(&self) -> &[MaybeUninit<T>]

Entire capacity of the underlying storage

source

pub fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>]

Entire capacity of the underlying storage

source

pub fn is_full(&self) -> bool

Returns true if the buffer is full.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 1> = ArrayDeque::new();

assert!(!buf.is_full());

buf.push_back(1);

assert!(buf.is_full());
source

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

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

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 2> = ArrayDeque::new();

buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.contains(&1), true);
assert_eq!(buf.contains(&3), false);
source

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

Provides a reference to the front element, or None if the sequence is empty.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 2> = ArrayDeque::new();
assert_eq!(buf.front(), None);

buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.front(), Some(&1));
source

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

Provides a mutable reference to the front element, or None if the sequence is empty.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 2> = ArrayDeque::new();
assert_eq!(buf.front_mut(), None);

buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.front_mut(), Some(&mut 1));
source

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

Provides a reference to the back element, or None if the sequence is empty.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 2> = ArrayDeque::new();

buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.back(), Some(&2));
source

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

Provides a mutable reference to the back element, or None if the sequence is empty.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 2> = ArrayDeque::new();

buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.back_mut(), Some(&mut 2));
source

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

Retrieves an element in the ArrayDeque by index.

Element at index 0 is the front of the queue.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();

buf.push_back(0);
buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.get(1), Some(&1));
source

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

Retrieves an element in the ArrayDeque mutably by index.

Element at index 0 is the front of the queue.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();

buf.push_back(0);
buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.get_mut(1), Some(&mut 1));
source

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

Returns a front-to-back iterator.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();

buf.push_back(0);
buf.push_back(1);
buf.push_back(2);

let expected = [0, 1, 2];

assert!(buf.iter().eq(expected.iter()));
source

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

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

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<usize, 3> = ArrayDeque::new();

buf.push_back(0);
buf.push_back(1);
buf.push_back(2);

let mut expected = [0, 1, 2];

assert!(buf.iter_mut().eq(expected.iter_mut()));
source

pub fn linearize(&mut self)

Make the buffer contiguous

The linearization may be required when interacting with external interfaces requiring contiguous slices.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<isize, 10> = ArrayDeque::new();
buf.extend_back([1, 2, 3]);
buf.extend_front([-1, -2, -3]);

buf.linearize();

assert_eq!(buf.as_slices().1.len(), 0);
§Complexity

Takes O(len()) time and no extra space.

source

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

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

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 2> = ArrayDeque::new();

buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.pop_front(), Some(1));
assert_eq!(buf.pop_front(), Some(2));
assert_eq!(buf.pop_front(), None);
source

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

Removes the last element from a buffer and returns it, or None if it is empty.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 2> = ArrayDeque::new();
assert_eq!(buf.pop_back(), None);

buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.pop_back(), Some(2));
assert_eq!(buf.pop_back(), Some(1));
source

pub fn clear(&mut self)

Clears the buffer, removing all values.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 1> = ArrayDeque::new();

buf.push_back(1);
buf.clear();

assert!(buf.is_empty());
source

pub fn drain<R>(&mut self, range: R) -> Drain<'_, T, CAP, B>
where R: RangeArgument<usize>,

Create a draining iterator that removes the specified range in the ArrayDeque and yields the removed items.

Note 1: The element range is removed even if the iterator is not consumed until the end.

Note 2: It is unspecified how many elements are removed from the deque, if the Drain value is not dropped, but the borrow it holds expires (eg. due to mem::forget).

§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
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();

buf.push_back(0);
buf.push_back(1);
buf.push_back(2);

{
    let drain = buf.drain(2..);
    assert!([2].into_iter().eq(drain));
}

{
    let iter = buf.iter();
    assert!([0, 1].iter().eq(iter));
}

// A full range clears all contents
buf.drain(..);
assert!(buf.is_empty());
source

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

Swaps elements at indices i and j.

i and j may be equal.

Fails if there is no element with either index.

Element at index 0 is the front of the queue.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();

buf.push_back(0);
buf.push_back(1);
buf.push_back(2);

buf.swap(0, 2);

assert_eq!(buf, [2, 1, 0].into());
source

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

Removes an element from anywhere in the ArrayDeque and returns it, replacing it with the last element.

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

Returns None if index is out of bounds.

Element at index 0 is the front of the queue.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();
assert_eq!(buf.swap_remove_back(0), None);

buf.push_back(0);
buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.swap_remove_back(0), Some(0));
assert_eq!(buf, [2, 1].into());
source

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

Removes an element from anywhere in the ArrayDeque and returns it, replacing it with the first element.

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

Returns None if index is out of bounds.

Element at index 0 is the front of the queue.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();
assert_eq!(buf.swap_remove_back(0), None);

buf.push_back(0);
buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.swap_remove_front(2), Some(2));
assert_eq!(buf, [1, 0].into());
source

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

Removes and returns the element at index from the ArrayDeque. Whichever end is closer to the removal point will be moved to make room, and all the affected elements will be moved to new positions. Returns None if index is out of bounds.

Element at index 0 is the front of the queue.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();

buf.push_back(0);
buf.push_back(1);
buf.push_back(2);

assert_eq!(buf.remove(1), Some(1));
assert_eq!(buf, [0, 2].into());
source

pub fn split_off(&mut self, at: usize) -> Self

Splits the collection into two at the given index.

Returns a newly allocated Self. self contains elements [0, at), and the returned Self contains elements [at, len).

Element at index 0 is the front of the queue.

§Panics

Panics if at > len

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 3> = ArrayDeque::new();

buf.push_back(0);
buf.push_back(1);
buf.push_back(2);

// buf = [0], buf2 = [1, 2]
let buf2 = buf.split_off(1);

assert_eq!(buf.len(), 1);
assert_eq!(buf2.len(), 2);
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 and preserves the order of the retained elements.

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 4> = ArrayDeque::new();

buf.extend_back(0..4);
buf.retain(|&x| x % 2 == 0);

assert_eq!(buf, [0, 2].into());
source

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

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

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 7> = ArrayDeque::new();

buf.push_back(0);
buf.push_back(1);

assert_eq!(buf.as_slices(), (&[0, 1][..], &[][..]));

buf.push_front(2);

assert_eq!(buf.as_slices(), (&[2][..], &[0, 1][..]));
source

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

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

§Examples
use arraydeque::ArrayDeque;

let mut buf: ArrayDeque<_, 7> = ArrayDeque::new();

buf.push_back(0);
buf.push_back(1);

assert_eq!(buf.as_mut_slices(), (&mut [0, 1][..], &mut[][..]));

buf.push_front(2);

assert_eq!(buf.as_mut_slices(), (&mut[2][..], &mut[0, 1][..]));

Trait Implementations§

source§

impl<T, const CAP: usize> Clone for ArrayDeque<T, CAP, Saturating>
where T: Clone,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
source§

impl<T, const CAP: usize> Clone for ArrayDeque<T, CAP, Wrapping>
where T: Clone,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
source§

impl<T, const CAP: usize, B: Behavior> Debug for ArrayDeque<T, CAP, B>
where T: Debug,

source§

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

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

impl<T, const CAP: usize, B: Behavior> Default for ArrayDeque<T, CAP, B>

source§

fn default() -> Self

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

impl<T, const CAP: usize, B: Behavior> Drop for ArrayDeque<T, CAP, B>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T, const CAP: usize> Extend<T> for ArrayDeque<T, CAP, Saturating>

source§

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

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

fn extend_one(&mut self, item: A)

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

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, const CAP: usize> Extend<T> for ArrayDeque<T, CAP, Wrapping>

source§

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

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

fn extend_one(&mut self, item: A)

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

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, const CAP: usize, const N: usize, B: Behavior> From<[T; N]> for ArrayDeque<T, CAP, B>
where Self: FromIterator<T>,

source§

fn from(arr: [T; N]) -> Self

Converts to this type from the input type.
source§

impl<T, const CAP: usize> From<ArrayDeque<T, CAP>> for ArrayDeque<T, CAP, Wrapping>

source§

fn from(buf: ArrayDeque<T, CAP, Saturating>) -> Self

Converts to this type from the input type.
source§

impl<T, const CAP: usize> From<ArrayDeque<T, CAP, Wrapping>> for ArrayDeque<T, CAP, Saturating>

source§

fn from(buf: ArrayDeque<T, CAP, Wrapping>) -> Self

Converts to this type from the input type.
source§

impl<T, const CAP: usize> FromIterator<T> for ArrayDeque<T, CAP, Saturating>

source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
source§

impl<T, const CAP: usize> FromIterator<T> for ArrayDeque<T, CAP, Wrapping>

source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
source§

impl<T, const CAP: usize, B: Behavior> Hash for ArrayDeque<T, CAP, B>
where T: Hash,

source§

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

Feeds this value into the given [Hasher]. Read more
1.3.0§

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, const CAP: usize, B: Behavior> Index<usize> for ArrayDeque<T, CAP, B>

§

type Output = T

The returned type after indexing.
source§

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

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

impl<T, const CAP: usize, B: Behavior> IndexMut<usize> for ArrayDeque<T, CAP, B>

source§

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

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

impl<'a, T, const CAP: usize, B: Behavior> IntoIterator for &'a ArrayDeque<T, CAP, B>

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, T>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T, const CAP: usize, B: Behavior> IntoIterator for &'a mut ArrayDeque<T, CAP, B>

§

type Item = &'a mut T

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, T>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T, const CAP: usize, B: Behavior> IntoIterator for ArrayDeque<T, CAP, B>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T, CAP, B>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T, const CAP: usize, B: Behavior> Ord for ArrayDeque<T, CAP, B>
where T: Ord,

source§

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

This method returns an [Ordering] between self and other. Read more
1.21.0§

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

Compares and returns the maximum of two values. Read more
1.21.0§

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

Compares and returns the minimum of two values. Read more
1.50.0§

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

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

impl<T, const CAP: usize, B: Behavior> PartialEq for ArrayDeque<T, CAP, B>
where T: PartialEq,

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, const CAP: usize, B: Behavior> PartialOrd for ArrayDeque<T, CAP, B>
where T: PartialOrd,

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T, const CAP: usize, B: Behavior> Eq for ArrayDeque<T, CAP, B>
where T: Eq,

Auto Trait Implementations§

§

impl<T, const CAP: usize, B> RefUnwindSafe for ArrayDeque<T, CAP, B>
where B: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, const CAP: usize, B> Send for ArrayDeque<T, CAP, B>
where B: Send, T: Send,

§

impl<T, const CAP: usize, B> Sync for ArrayDeque<T, CAP, B>
where B: Sync, T: Sync,

§

impl<T, const CAP: usize, B> Unpin for ArrayDeque<T, CAP, B>
where B: Unpin, T: Unpin,

§

impl<T, const CAP: usize, B> UnwindSafe for ArrayDeque<T, CAP, B>
where B: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.