Struct VecDeque

1.0.0 ยท Source
pub struct VecDeque<T, A = Global>
where A: Allocator,
{ /* private fields */ }
Available on crate feature alloc only.
Expand description

๐Ÿ“ฆ alloc A double-ended growable queue.

Re-exported from [alloc]::collections:: .


A double-ended queue implemented with a growable 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 the queue. extend and append push onto the back in this manner, and iterating over VecDeque goes front to back.

A VecDeque with a known list of items can be initialized from an array:

use std::collections::VecDeque;

let deq = VecDeque::from([-1, 0, 1]);

Since VecDeque 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 VecDeque so that its elements do not wrap, and returns a mutable slice to the now-contiguous element sequence.

Implementationsยง

Sourceยง

impl<T> VecDeque<T>

1.0.0 (const: 1.68.0) ยท Source

pub const fn new() -> VecDeque<T>

Creates an empty deque.

ยงExamples
use std::collections::VecDeque;

let deque: VecDeque<u32> = VecDeque::new();
1.0.0 ยท Source

pub fn with_capacity(capacity: usize) -> VecDeque<T>

Creates an empty deque with space for at least capacity elements.

ยงExamples
use std::collections::VecDeque;

let deque: VecDeque<u32> = VecDeque::with_capacity(10);
Source

pub fn try_with_capacity( capacity: usize, ) -> Result<VecDeque<T>, TryReserveError> โ“˜

๐Ÿ”ฌThis is a nightly-only experimental API. (try_with_capacity)

Creates an empty deque with space for at least capacity elements.

ยงErrors

Returns an error if the capacity exceeds isize::MAX bytes, or if the allocator reports allocation failure.

ยงExamples
use std::collections::VecDeque;

let deque: VecDeque<u32> = VecDeque::try_with_capacity(10)?;
Sourceยง

impl<T, A> VecDeque<T, A>
where A: Allocator,

Source

pub const fn new_in(alloc: A) -> VecDeque<T, A>

๐Ÿ”ฌThis is a nightly-only experimental API. (allocator_api)

Creates an empty deque.

ยงExamples
use std::collections::VecDeque;

let deque: VecDeque<u32> = VecDeque::new();
Source

pub fn with_capacity_in(capacity: usize, alloc: A) -> VecDeque<T, A>

๐Ÿ”ฌThis is a nightly-only experimental API. (allocator_api)

Creates an empty deque with space for at least capacity elements.

ยงExamples
use std::collections::VecDeque;

let deque: VecDeque<u32> = VecDeque::with_capacity(10);
1.0.0 ยท Source

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

Provides a reference to the element at the given index.

Element at index 0 is the front of the queue.

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.push_back(3);
buf.push_back(4);
buf.push_back(5);
buf.push_back(6);
assert_eq!(buf.get(1), Some(&4));
1.0.0 ยท Source

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

Provides a mutable reference to the element at the given index.

Element at index 0 is the front of the queue.

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.push_back(3);
buf.push_back(4);
buf.push_back(5);
buf.push_back(6);
assert_eq!(buf[1], 4);
if let Some(elem) = buf.get_mut(1) {
    *elem = 7;
}
assert_eq!(buf[1], 7);
1.0.0 ยท Source

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

Swaps elements at indices i and j.

i and j may be equal.

Element at index 0 is the front of the queue.

ยงPanics

Panics if either index is out of bounds.

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.push_back(3);
buf.push_back(4);
buf.push_back(5);
assert_eq!(buf, [3, 4, 5]);
buf.swap(0, 2);
assert_eq!(buf, [5, 4, 3]);
1.0.0 ยท Source

pub fn capacity(&self) -> usize

Returns the number of elements the deque can hold without reallocating.

ยงExamples
use std::collections::VecDeque;

let buf: VecDeque<i32> = VecDeque::with_capacity(10);
assert!(buf.capacity() >= 10);
1.0.0 ยท Source

pub fn reserve_exact(&mut self, additional: usize)

Reserves the minimum capacity for at least additional more elements to be inserted in the given deque. Does nothing if the capacity is already sufficient.

Note that the allocator may give the collection more space than it requests. Therefore capacity can not be relied upon to be precisely minimal. Prefer reserve if future insertions are expected.

ยงPanics

Panics if the new capacity overflows usize.

ยงExamples
use std::collections::VecDeque;

let mut buf: VecDeque<i32> = [1].into();
buf.reserve_exact(10);
assert!(buf.capacity() >= 11);
1.0.0 ยท Source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more elements to be inserted in the given deque. The collection may reserve more space to speculatively avoid frequent reallocations.

ยงPanics

Panics if the new capacity overflows usize.

ยงExamples
use std::collections::VecDeque;

let mut buf: VecDeque<i32> = [1].into();
buf.reserve(10);
assert!(buf.capacity() >= 11);
1.57.0 ยท Source

pub fn try_reserve_exact( &mut self, additional: usize, ) -> Result<(), TryReserveError> โ“˜

Tries to reserve the minimum capacity for at least additional more elements to be inserted in the given deque. After calling try_reserve_exact, capacity will be greater than or equal to self.len() + additional if it returns Ok(()). Does nothing if the capacity is already sufficient.

Note that the allocator may give the collection more space than it requests. Therefore, capacity can not be relied upon to be precisely minimal. Prefer try_reserve if future insertions are expected.

ยงErrors

If the capacity overflows usize, or the allocator reports a failure, then an error is returned.

ยงExamples
use std::collections::TryReserveError;
use std::collections::VecDeque;

fn process_data(data: &[u32]) -> Result<VecDeque<u32>, TryReserveError> {
    let mut output = VecDeque::new();

    // Pre-reserve the memory, exiting if we can't
    output.try_reserve_exact(data.len())?;

    // Now we know this can't OOM(Out-Of-Memory) in the middle of our complex work
    output.extend(data.iter().map(|&val| {
        val * 2 + 5 // very complicated
    }));

    Ok(output)
}
1.57.0 ยท Source

pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> โ“˜

Tries to reserve capacity for at least additional more elements to be inserted in the given deque. The collection may reserve more space to speculatively avoid frequent reallocations. After calling try_reserve, capacity will be greater than or equal to self.len() + additional if it returns Ok(()). Does nothing if capacity is already sufficient. This method preserves the contents even if an error occurs.

ยงErrors

If the capacity overflows usize, or the allocator reports a failure, then an error is returned.

ยงExamples
use std::collections::TryReserveError;
use std::collections::VecDeque;

fn process_data(data: &[u32]) -> Result<VecDeque<u32>, TryReserveError> {
    let mut output = VecDeque::new();

    // Pre-reserve the memory, exiting if we can't
    output.try_reserve(data.len())?;

    // Now we know this can't OOM in the middle of our complex work
    output.extend(data.iter().map(|&val| {
        val * 2 + 5 // very complicated
    }));

    Ok(output)
}
1.5.0 ยท Source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of the deque as much as possible.

It will drop down as close as possible to the length but the allocator may still inform the deque that there is space for a few more elements.

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::with_capacity(15);
buf.extend(0..4);
assert_eq!(buf.capacity(), 15);
buf.shrink_to_fit();
assert!(buf.capacity() >= 4);
1.56.0 ยท Source

pub fn shrink_to(&mut self, min_capacity: usize)

Shrinks the capacity of the deque with a lower bound.

The capacity will remain at least as large as both the length and the supplied value.

If the current capacity is less than the lower limit, this is a no-op.

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::with_capacity(15);
buf.extend(0..4);
assert_eq!(buf.capacity(), 15);
buf.shrink_to(6);
assert!(buf.capacity() >= 6);
buf.shrink_to(0);
assert!(buf.capacity() >= 4);
1.16.0 ยท Source

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

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

If len is greater or equal to the dequeโ€™s current length, this has no effect.

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.push_back(5);
buf.push_back(10);
buf.push_back(15);
assert_eq!(buf, [5, 10, 15]);
buf.truncate(1);
assert_eq!(buf, [5]);
Source

pub fn allocator(&self) -> &A

๐Ÿ”ฌThis is a nightly-only experimental API. (allocator_api)

Returns a reference to the underlying allocator.

1.0.0 ยท Source

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

Returns a front-to-back iterator.

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.push_back(5);
buf.push_back(3);
buf.push_back(4);
let b: &[_] = &[&5, &3, &4];
let c: Vec<&i32> = buf.iter().collect();
assert_eq!(&c[..], b);
1.0.0 ยท Source

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

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

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.push_back(5);
buf.push_back(3);
buf.push_back(4);
for num in buf.iter_mut() {
    *num = *num - 2;
}
let b: &[_] = &[&mut 3, &mut 1, &mut 2];
assert_eq!(&buf.iter_mut().collect::<Vec<&mut i32>>()[..], b);
1.5.0 ยท 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
use std::collections::VecDeque;

let mut deque = VecDeque::new();

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

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

deque.push_front(10);
deque.push_front(9);

assert_eq!(deque.as_slices(), (&[9, 10][..], &[0, 1, 2][..]));
1.5.0 ยท 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 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
use std::collections::VecDeque;

let mut deque = VecDeque::new();

deque.push_back(0);
deque.push_back(1);

deque.push_front(10);
deque.push_front(9);

deque.as_mut_slices().0[0] = 42;
deque.as_mut_slices().1[0] = 24;
assert_eq!(deque.as_slices(), (&[42, 10][..], &[24, 1][..]));
1.0.0 ยท Source

pub fn len(&self) -> usize

Returns the number of elements in the deque.

ยงExamples
use std::collections::VecDeque;

let mut deque = VecDeque::new();
assert_eq!(deque.len(), 0);
deque.push_back(1);
assert_eq!(deque.len(), 1);
1.0.0 ยท Source

pub fn is_empty(&self) -> bool

Returns true if the deque is empty.

ยงExamples
use std::collections::VecDeque;

let mut deque = VecDeque::new();
assert!(deque.is_empty());
deque.push_front(1);
assert!(!deque.is_empty());
1.51.0 ยท Source

pub fn range<R>(&self, range: R) -> Iter<'_, T> โ“˜
where R: RangeBounds<usize>,

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
use std::collections::VecDeque;

let deque: VecDeque<_> = [1, 2, 3].into();
let range = deque.range(2..).copied().collect::<VecDeque<_>>();
assert_eq!(range, [3]);

// A full range covers all contents
let all = deque.range(..);
assert_eq!(all.len(), 3);
1.51.0 ยท Source

pub fn range_mut<R>(&mut self, range: R) -> IterMut<'_, T> โ“˜
where R: RangeBounds<usize>,

Creates an iterator that covers the specified mutable 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
use std::collections::VecDeque;

let mut deque: VecDeque<_> = [1, 2, 3].into();
for v in deque.range_mut(2..) {
  *v *= 2;
}
assert_eq!(deque, [1, 2, 6]);

// A full range covers all contents
for v in deque.range_mut(..) {
  *v *= 2;
}
assert_eq!(deque, [2, 4, 12]);
1.6.0 ยท Source

pub fn drain<R>(&mut self, range: R) -> Drain<'_, T, A> โ“˜
where R: RangeBounds<usize>,

Removes the specified range from the deque in bulk, returning all removed elements as an iterator. If the iterator is dropped before being fully consumed, it drops the remaining removed elements.

The returned iterator keeps a mutable borrow on the queue to optimize its implementation.

ยง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.

ยงLeaking

If the returned iterator goes out of scope without being dropped (due to mem::forget, for example), the deque may have lost and leaked elements arbitrarily, including elements outside the range.

ยงExamples
use std::collections::VecDeque;

let mut deque: VecDeque<_> = [1, 2, 3].into();
let drained = deque.drain(2..).collect::<VecDeque<_>>();
assert_eq!(drained, [3]);
assert_eq!(deque, [1, 2]);

// A full range clears all contents, like `clear()` does
deque.drain(..);
assert!(deque.is_empty());
1.0.0 ยท Source

pub fn clear(&mut self)

Clears the deque, removing all values.

ยงExamples
use std::collections::VecDeque;

let mut deque = VecDeque::new();
deque.push_back(1);
deque.clear();
assert!(deque.is_empty());
1.12.0 ยท Source

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

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

This operation is O(n).

Note that if you have a sorted VecDeque, binary_search may be faster.

ยงExamples
use std::collections::VecDeque;

let mut deque: VecDeque<u32> = VecDeque::new();

deque.push_back(0);
deque.push_back(1);

assert_eq!(deque.contains(&1), true);
assert_eq!(deque.contains(&10), false);
1.0.0 ยท Source

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

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

ยงExamples
use std::collections::VecDeque;

let mut d = VecDeque::new();
assert_eq!(d.front(), None);

d.push_back(1);
d.push_back(2);
assert_eq!(d.front(), Some(&1));
1.0.0 ยท Source

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

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

ยงExamples
use std::collections::VecDeque;

let mut d = VecDeque::new();
assert_eq!(d.front_mut(), None);

d.push_back(1);
d.push_back(2);
match d.front_mut() {
    Some(x) => *x = 9,
    None => (),
}
assert_eq!(d.front(), Some(&9));
1.0.0 ยท Source

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

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

ยงExamples
use std::collections::VecDeque;

let mut d = VecDeque::new();
assert_eq!(d.back(), None);

d.push_back(1);
d.push_back(2);
assert_eq!(d.back(), Some(&2));
1.0.0 ยท Source

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

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

ยงExamples
use std::collections::VecDeque;

let mut d = VecDeque::new();
assert_eq!(d.back(), None);

d.push_back(1);
d.push_back(2);
match d.back_mut() {
    Some(x) => *x = 9,
    None => (),
}
assert_eq!(d.back(), Some(&9));
1.0.0 ยท Source

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

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

ยงExamples
use std::collections::VecDeque;

let mut d = VecDeque::new();
d.push_back(1);
d.push_back(2);

assert_eq!(d.pop_front(), Some(1));
assert_eq!(d.pop_front(), Some(2));
assert_eq!(d.pop_front(), None);
1.0.0 ยท Source

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

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

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::new();
assert_eq!(buf.pop_back(), None);
buf.push_back(1);
buf.push_back(3);
assert_eq!(buf.pop_back(), Some(3));
Source

pub fn pop_front_if( &mut self, predicate: impl FnOnce(&mut T) -> bool, ) -> Option<T> โ“˜

๐Ÿ”ฌThis is a nightly-only experimental API. (vec_deque_pop_if)

Removes and returns the first element from the deque if the predicate returns true, or None if the predicate returns false or the deque is empty (the predicate will not be called in that case).

ยงExamples
#![feature(vec_deque_pop_if)]
use std::collections::VecDeque;

let mut deque: VecDeque<i32> = vec![0, 1, 2, 3, 4].into();
let pred = |x: &mut i32| *x % 2 == 0;

assert_eq!(deque.pop_front_if(pred), Some(0));
assert_eq!(deque, [1, 2, 3, 4]);
assert_eq!(deque.pop_front_if(pred), None);
Source

pub fn pop_back_if( &mut self, predicate: impl FnOnce(&mut T) -> bool, ) -> Option<T> โ“˜

๐Ÿ”ฌThis is a nightly-only experimental API. (vec_deque_pop_if)

Removes and returns the last element from the deque if the predicate returns true, or None if the predicate returns false or the deque is empty (the predicate will not be called in that case).

ยงExamples
#![feature(vec_deque_pop_if)]
use std::collections::VecDeque;

let mut deque: VecDeque<i32> = vec![0, 1, 2, 3, 4].into();
let pred = |x: &mut i32| *x % 2 == 0;

assert_eq!(deque.pop_back_if(pred), Some(4));
assert_eq!(deque, [0, 1, 2, 3]);
assert_eq!(deque.pop_back_if(pred), None);
1.0.0 ยท Source

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

Prepends an element to the deque.

ยงExamples
use std::collections::VecDeque;

let mut d = VecDeque::new();
d.push_front(1);
d.push_front(2);
assert_eq!(d.front(), Some(&2));
1.0.0 ยท Source

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

Appends an element to the back of the deque.

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.push_back(1);
buf.push_back(3);
assert_eq!(3, *buf.back().unwrap());
1.5.0 ยท Source

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

Removes an element from anywhere in the deque 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 std::collections::VecDeque;

let mut buf = VecDeque::new();
assert_eq!(buf.swap_remove_front(0), None);
buf.push_back(1);
buf.push_back(2);
buf.push_back(3);
assert_eq!(buf, [1, 2, 3]);

assert_eq!(buf.swap_remove_front(2), Some(3));
assert_eq!(buf, [2, 1]);
1.5.0 ยท Source

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

Removes an element from anywhere in the deque 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 std::collections::VecDeque;

let mut buf = VecDeque::new();
assert_eq!(buf.swap_remove_back(0), None);
buf.push_back(1);
buf.push_back(2);
buf.push_back(3);
assert_eq!(buf, [1, 2, 3]);

assert_eq!(buf.swap_remove_back(0), Some(1));
assert_eq!(buf, [3, 2]);
1.5.0 ยท Source

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

Inserts an element at index within the deque, shifting all elements with indices greater than or equal to index towards the back.

Element at index 0 is the front of the queue.

ยงPanics

Panics if index is strictly greater than dequeโ€™s length

ยงExamples
use std::collections::VecDeque;

let mut vec_deque = VecDeque::new();
vec_deque.push_back('a');
vec_deque.push_back('b');
vec_deque.push_back('c');
assert_eq!(vec_deque, &['a', 'b', 'c']);

vec_deque.insert(1, 'd');
assert_eq!(vec_deque, &['a', 'd', 'b', 'c']);

vec_deque.insert(4, 'e');
assert_eq!(vec_deque, &['a', 'd', 'b', 'c', 'e']);
1.0.0 ยท Source

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

Removes and returns the element at index from the deque. 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 std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.push_back('a');
buf.push_back('b');
buf.push_back('c');
assert_eq!(buf, ['a', 'b', 'c']);

assert_eq!(buf.remove(1), Some('b'));
assert_eq!(buf, ['a', 'c']);
1.4.0 ยท Source

pub fn split_off(&mut self, at: usize) -> VecDeque<T, A>
where A: Clone,

Splits the deque into two at the given index.

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

Note that the capacity of self does not change.

Element at index 0 is the front of the queue.

ยงPanics

Panics if at > len.

ยงExamples
use std::collections::VecDeque;

let mut buf: VecDeque<_> = ['a', 'b', 'c'].into();
let buf2 = buf.split_off(1);
assert_eq!(buf, ['a']);
assert_eq!(buf2, ['b', 'c']);
1.4.0 ยท Source

pub fn append(&mut self, other: &mut VecDeque<T, A>)

Moves all the elements of other into self, leaving other empty.

ยงPanics

Panics if the new number of elements in self overflows a usize.

ยงExamples
use std::collections::VecDeque;

let mut buf: VecDeque<_> = [1, 2].into();
let mut buf2: VecDeque<_> = [3, 4].into();
buf.append(&mut buf2);
assert_eq!(buf, [1, 2, 3, 4]);
assert_eq!(buf2, []);
1.4.0 ยท 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 for which 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
use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.extend(1..5);
buf.retain(|&x| x % 2 == 0);
assert_eq!(buf, [2, 4]);

Because the elements are visited exactly once in the original order, external state may be used to decide which elements to keep.

use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.extend(1..6);

let keep = [false, true, true, false, true];
let mut iter = keep.iter();
buf.retain(|_| *iter.next().unwrap());
assert_eq!(buf, [2, 3, 5]);
1.61.0 ยท Source

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

Retains only the elements specified by the predicate.

In other words, remove all elements e for which f(&mut 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
use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.extend(1..5);
buf.retain_mut(|x| if *x % 2 == 0 {
    *x += 1;
    true
} else {
    false
});
assert_eq!(buf, [3, 5]);
1.33.0 ยท Source

pub fn resize_with(&mut self, new_len: usize, generator: impl FnMut() -> T)

Modifies the deque in-place so that len() is equal to new_len, either by removing excess elements from the back or by appending elements generated by calling generator to the back.

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.push_back(5);
buf.push_back(10);
buf.push_back(15);
assert_eq!(buf, [5, 10, 15]);

buf.resize_with(5, Default::default);
assert_eq!(buf, [5, 10, 15, 0, 0]);

buf.resize_with(2, || unreachable!());
assert_eq!(buf, [5, 10]);

let mut state = 100;
buf.resize_with(5, || { state += 1; state });
assert_eq!(buf, [5, 10, 101, 102, 103]);
1.48.0 ยท Source

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

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

This method does not allocate and does not change the order of the inserted elements. As it returns a mutable slice, this can be used to sort 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

Sorting the content of a deque.

use std::collections::VecDeque;

let mut buf = VecDeque::with_capacity(15);

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

// sorting the deque
buf.make_contiguous().sort();
assert_eq!(buf.as_slices(), (&[1, 2, 3] as &[_], &[] as &[_]));

// sorting it in reverse order
buf.make_contiguous().sort_by(|a, b| b.cmp(a));
assert_eq!(buf.as_slices(), (&[3, 2, 1] as &[_], &[] as &[_]));

Getting immutable access to the contiguous slice.

use std::collections::VecDeque;

let mut buf = VecDeque::new();

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

buf.make_contiguous();
if let (slice, &[]) = buf.as_slices() {
    // we can now be sure that `slice` contains all elements of the deque,
    // while still having immutable access to `buf`.
    assert_eq!(buf.len(), slice.len());
    assert_eq!(slice, &[3, 2, 1] as &[_]);
}
1.36.0 ยท Source

pub fn rotate_left(&mut self, n: usize)

Rotates the double-ended queue n places to the left.

Equivalently,

  • Rotates item n into the first position.
  • Pops the first n items and pushes them to the end.
  • Rotates len() - n places to the right.
ยงPanics

If n is greater than len(). Note that n == len() does not panic and is a no-op rotation.

ยงComplexity

Takes *O*(min(n, len() - n)) time and no extra space.

ยงExamples
use std::collections::VecDeque;

let mut buf: VecDeque<_> = (0..10).collect();

buf.rotate_left(3);
assert_eq!(buf, [3, 4, 5, 6, 7, 8, 9, 0, 1, 2]);

for i in 1..10 {
    assert_eq!(i * 3 % 10, buf[0]);
    buf.rotate_left(3);
}
assert_eq!(buf, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
1.36.0 ยท Source

pub fn rotate_right(&mut self, n: usize)

Rotates the double-ended queue n places to the right.

Equivalently,

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

If n is greater than len(). Note that n == len() does not panic and is a no-op rotation.

ยงComplexity

Takes *O*(min(n, len() - n)) time and no extra space.

ยงExamples
use std::collections::VecDeque;

let mut buf: VecDeque<_> = (0..10).collect();

buf.rotate_right(3);
assert_eq!(buf, [7, 8, 9, 0, 1, 2, 3, 4, 5, 6]);

for i in 1..10 {
    assert_eq!(0, buf[i * 3 % 10]);
    buf.rotate_right(3);
}
assert_eq!(buf, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);

Binary searches this VecDeque for a given element. If the VecDeque is not sorted, the returned result is unspecified and meaningless.

If the value is found then Result::Ok is returned, containing the index of the matching element. If there are multiple matches, then any one of the matches could be returned. If the value is not found then Result::Err is returned, containing the index where a matching element could be inserted while maintaining sorted order.

See also binary_search_by, binary_search_by_key, and partition_point.

ยงExamples

Looks up a series of four elements. The first is found, with a uniquely determined position; the second and third are not found; the fourth could match any position in [1, 4].

use std::collections::VecDeque;

let deque: VecDeque<_> = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into();

assert_eq!(deque.binary_search(&13),  Ok(9));
assert_eq!(deque.binary_search(&4),   Err(7));
assert_eq!(deque.binary_search(&100), Err(13));
let r = deque.binary_search(&1);
assert!(matches!(r, Ok(1..=4)));

If you want to insert an item to a sorted deque, while maintaining sort order, consider using partition_point:

use std::collections::VecDeque;

let mut deque: VecDeque<_> = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into();
let num = 42;
let idx = deque.partition_point(|&x| x <= num);
// If `num` is unique, `s.partition_point(|&x| x < num)` (with `<`) is equivalent to
// `s.binary_search(&num).unwrap_or_else(|x| x)`, but using `<=` may allow `insert`
// to shift less elements.
deque.insert(idx, num);
assert_eq!(deque, &[0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
1.54.0 ยท Source

pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize> โ“˜
where F: FnMut(&'a T) -> Ordering,

Binary searches this VecDeque with a comparator function.

The comparator function should return an order code that indicates whether its argument is Less, Equal or Greater the desired target. If the VecDeque is not sorted or if the comparator function does not implement an order consistent with the sort order of the underlying VecDeque, the returned result is unspecified and meaningless.

If the value is found then Result::Ok is returned, containing the index of the matching element. If there are multiple matches, then any one of the matches could be returned. If the value is not found then Result::Err is returned, containing the index where a matching element could be inserted while maintaining sorted order.

See also binary_search, binary_search_by_key, and partition_point.

ยงExamples

Looks up a series of four elements. The first is found, with a uniquely determined position; the second and third are not found; the fourth could match any position in [1, 4].

use std::collections::VecDeque;

let deque: VecDeque<_> = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into();

assert_eq!(deque.binary_search_by(|x| x.cmp(&13)),  Ok(9));
assert_eq!(deque.binary_search_by(|x| x.cmp(&4)),   Err(7));
assert_eq!(deque.binary_search_by(|x| x.cmp(&100)), Err(13));
let r = deque.binary_search_by(|x| x.cmp(&1));
assert!(matches!(r, Ok(1..=4)));
1.54.0 ยท Source

pub fn binary_search_by_key<'a, B, F>( &'a self, b: &B, f: F, ) -> Result<usize, usize> โ“˜
where F: FnMut(&'a T) -> B, B: Ord,

Binary searches this VecDeque with a key extraction function.

Assumes that the deque is sorted by the key, for instance with make_contiguous().sort_by_key() using the same key extraction function. If the deque is not sorted by the key, the returned result is unspecified and meaningless.

If the value is found then Result::Ok is returned, containing the index of the matching element. If there are multiple matches, then any one of the matches could be returned. If the value is not found then Result::Err is returned, containing the index where a matching element could be inserted while maintaining sorted order.

See also binary_search, binary_search_by, and partition_point.

ยงExamples

Looks up a series of four elements in a slice of pairs sorted by their second elements. The first is found, with a uniquely determined position; the second and third are not found; the fourth could match any position in [1, 4].

use std::collections::VecDeque;

let deque: VecDeque<_> = [(0, 0), (2, 1), (4, 1), (5, 1),
         (3, 1), (1, 2), (2, 3), (4, 5), (5, 8), (3, 13),
         (1, 21), (2, 34), (4, 55)].into();

assert_eq!(deque.binary_search_by_key(&13, |&(a, b)| b),  Ok(9));
assert_eq!(deque.binary_search_by_key(&4, |&(a, b)| b),   Err(7));
assert_eq!(deque.binary_search_by_key(&100, |&(a, b)| b), Err(13));
let r = deque.binary_search_by_key(&1, |&(a, b)| b);
assert!(matches!(r, Ok(1..=4)));
1.54.0 ยท Source

pub fn partition_point<P>(&self, pred: P) -> usize
where P: FnMut(&T) -> bool,

Returns the index of the partition point according to the given predicate (the index of the first element of the second partition).

The deque is assumed to be partitioned according to the given predicate. This means that all elements for which the predicate returns true are at the start of the deque and all elements for which the predicate returns false are at the end. For example, [7, 15, 3, 5, 4, 12, 6] is partitioned under the predicate x % 2 != 0 (all odd numbers are at the start, all even at the end).

If the deque is not partitioned, the returned result is unspecified and meaningless, as this method performs a kind of binary search.

See also binary_search, binary_search_by, and binary_search_by_key.

ยงExamples
use std::collections::VecDeque;

let deque: VecDeque<_> = [1, 2, 3, 3, 5, 6, 7].into();
let i = deque.partition_point(|&x| x < 5);

assert_eq!(i, 4);
assert!(deque.iter().take(i).all(|&x| x < 5));
assert!(deque.iter().skip(i).all(|&x| !(x < 5)));

If you want to insert an item to a sorted deque, while maintaining sort order:

use std::collections::VecDeque;

let mut deque: VecDeque<_> = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into();
let num = 42;
let idx = deque.partition_point(|&x| x < num);
deque.insert(idx, num);
assert_eq!(deque, &[0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
Sourceยง

impl<T, A> VecDeque<T, A>
where T: Clone, A: Allocator,

1.16.0 ยท Source

pub fn resize(&mut self, new_len: usize, value: T)

Modifies the deque in-place so that len() is equal to new_len, either by removing excess elements from the back or by appending clones of value to the back.

ยงExamples
use std::collections::VecDeque;

let mut buf = VecDeque::new();
buf.push_back(5);
buf.push_back(10);
buf.push_back(15);
assert_eq!(buf, [5, 10, 15]);

buf.resize(2, 0);
assert_eq!(buf, [5, 10]);

buf.resize(5, 20);
assert_eq!(buf, [5, 10, 20, 20, 20]);

Trait Implementationsยง

Sourceยง

impl<T> BitSized<{$PTR_BITS * 3}> for VecDeque<T>

Sourceยง

const BIT_SIZE: usize = _

The bit size of this type (only the relevant data part, without padding). Read more
Sourceยง

const MIN_BYTE_SIZE: usize = _

The rounded up byte size for this type. Read more
Sourceยง

fn bit_size(&self) -> usize

Returns the bit size of this type (only the relevant data part, without padding). Read more
Sourceยง

fn min_byte_size(&self) -> usize

Returns the rounded up byte size for this type. Read more
ยง

impl Buf for VecDeque<u8>

ยง

fn remaining(&self) -> usize

Returns the number of bytes between the current position and the end of the buffer. Read more
ยง

fn chunk(&self) -> &[u8] โ“˜

Returns a slice starting at the current position and of length between 0 and Buf::remaining(). Note that this can return a shorter slice (this allows non-continuous internal representation). Read more
ยง

fn chunks_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize

Fills dst with potentially multiple slices starting at selfโ€™s current position. Read more
ยง

fn advance(&mut self, cnt: usize)

Advance the internal cursor of the Buf Read more
ยง

fn has_remaining(&self) -> bool

Returns true if there are any more bytes to consume Read more
ยง

fn copy_to_slice(&mut self, dst: &mut [u8])

Copies bytes from self into dst. Read more
ยง

fn get_u8(&mut self) -> u8

Gets an unsigned 8 bit integer from self. Read more
ยง

fn get_i8(&mut self) -> i8

Gets a signed 8 bit integer from self. Read more
ยง

fn get_u16(&mut self) -> u16

Gets an unsigned 16 bit integer from self in big-endian byte order. Read more
ยง

fn get_u16_le(&mut self) -> u16

Gets an unsigned 16 bit integer from self in little-endian byte order. Read more
ยง

fn get_u16_ne(&mut self) -> u16

Gets an unsigned 16 bit integer from self in native-endian byte order. Read more
ยง

fn get_i16(&mut self) -> i16

Gets a signed 16 bit integer from self in big-endian byte order. Read more
ยง

fn get_i16_le(&mut self) -> i16

Gets a signed 16 bit integer from self in little-endian byte order. Read more
ยง

fn get_i16_ne(&mut self) -> i16

Gets a signed 16 bit integer from self in native-endian byte order. Read more
ยง

fn get_u32(&mut self) -> u32 โ“˜

Gets an unsigned 32 bit integer from self in the big-endian byte order. Read more
ยง

fn get_u32_le(&mut self) -> u32 โ“˜

Gets an unsigned 32 bit integer from self in the little-endian byte order. Read more
ยง

fn get_u32_ne(&mut self) -> u32 โ“˜

Gets an unsigned 32 bit integer from self in native-endian byte order. Read more
ยง

fn get_i32(&mut self) -> i32

Gets a signed 32 bit integer from self in big-endian byte order. Read more
ยง

fn get_i32_le(&mut self) -> i32

Gets a signed 32 bit integer from self in little-endian byte order. Read more
ยง

fn get_i32_ne(&mut self) -> i32

Gets a signed 32 bit integer from self in native-endian byte order. Read more
ยง

fn get_u64(&mut self) -> u64

Gets an unsigned 64 bit integer from self in big-endian byte order. Read more
ยง

fn get_u64_le(&mut self) -> u64

Gets an unsigned 64 bit integer from self in little-endian byte order. Read more
ยง

fn get_u64_ne(&mut self) -> u64

Gets an unsigned 64 bit integer from self in native-endian byte order. Read more
ยง

fn get_i64(&mut self) -> i64 โ“˜

Gets a signed 64 bit integer from self in big-endian byte order. Read more
ยง

fn get_i64_le(&mut self) -> i64 โ“˜

Gets a signed 64 bit integer from self in little-endian byte order. Read more
ยง

fn get_i64_ne(&mut self) -> i64 โ“˜

Gets a signed 64 bit integer from self in native-endian byte order. Read more
ยง

fn get_u128(&mut self) -> u128

Gets an unsigned 128 bit integer from self in big-endian byte order. Read more
ยง

fn get_u128_le(&mut self) -> u128

Gets an unsigned 128 bit integer from self in little-endian byte order. Read more
ยง

fn get_u128_ne(&mut self) -> u128

Gets an unsigned 128 bit integer from self in native-endian byte order. Read more
ยง

fn get_i128(&mut self) -> i128

Gets a signed 128 bit integer from self in big-endian byte order. Read more
ยง

fn get_i128_le(&mut self) -> i128

Gets a signed 128 bit integer from self in little-endian byte order. Read more
ยง

fn get_i128_ne(&mut self) -> i128

Gets a signed 128 bit integer from self in native-endian byte order. Read more
ยง

fn get_uint(&mut self, nbytes: usize) -> u64

Gets an unsigned n-byte integer from self in big-endian byte order. Read more
ยง

fn get_uint_le(&mut self, nbytes: usize) -> u64

Gets an unsigned n-byte integer from self in little-endian byte order. Read more
ยง

fn get_uint_ne(&mut self, nbytes: usize) -> u64

Gets an unsigned n-byte integer from self in native-endian byte order. Read more
ยง

fn get_int(&mut self, nbytes: usize) -> i64 โ“˜

Gets a signed n-byte integer from self in big-endian byte order. Read more
ยง

fn get_int_le(&mut self, nbytes: usize) -> i64 โ“˜

Gets a signed n-byte integer from self in little-endian byte order. Read more
ยง

fn get_int_ne(&mut self, nbytes: usize) -> i64 โ“˜

Gets a signed n-byte integer from self in native-endian byte order. Read more
ยง

fn get_f32(&mut self) -> f32

Gets an IEEE754 single-precision (4 bytes) floating point number from self in big-endian byte order. Read more
ยง

fn get_f32_le(&mut self) -> f32

Gets an IEEE754 single-precision (4 bytes) floating point number from self in little-endian byte order. Read more
ยง

fn get_f32_ne(&mut self) -> f32

Gets an IEEE754 single-precision (4 bytes) floating point number from self in native-endian byte order. Read more
ยง

fn get_f64(&mut self) -> f64 โ“˜

Gets an IEEE754 double-precision (8 bytes) floating point number from self in big-endian byte order. Read more
ยง

fn get_f64_le(&mut self) -> f64 โ“˜

Gets an IEEE754 double-precision (8 bytes) floating point number from self in little-endian byte order. Read more
ยง

fn get_f64_ne(&mut self) -> f64 โ“˜

Gets an IEEE754 double-precision (8 bytes) floating point number from self in native-endian byte order. Read more
ยง

fn try_copy_to_slice(&mut self, dst: &mut [u8]) -> Result<(), TryGetError> โ“˜

Copies bytes from self into dst. Read more
ยง

fn try_get_u8(&mut self) -> Result<u8, TryGetError> โ“˜

Gets an unsigned 8 bit integer from self. Read more
ยง

fn try_get_i8(&mut self) -> Result<i8, TryGetError> โ“˜

Gets a signed 8 bit integer from self. Read more
ยง

fn try_get_u16(&mut self) -> Result<u16, TryGetError> โ“˜

Gets an unsigned 16 bit integer from self in big-endian byte order. Read more
ยง

fn try_get_u16_le(&mut self) -> Result<u16, TryGetError> โ“˜

Gets an unsigned 16 bit integer from self in little-endian byte order. Read more
ยง

fn try_get_u16_ne(&mut self) -> Result<u16, TryGetError> โ“˜

Gets an unsigned 16 bit integer from self in native-endian byte order. Read more
ยง

fn try_get_i16(&mut self) -> Result<i16, TryGetError> โ“˜

Gets a signed 16 bit integer from self in big-endian byte order. Read more
ยง

fn try_get_i16_le(&mut self) -> Result<i16, TryGetError> โ“˜

Gets an signed 16 bit integer from self in little-endian byte order. Read more
ยง

fn try_get_i16_ne(&mut self) -> Result<i16, TryGetError> โ“˜

Gets a signed 16 bit integer from self in native-endian byte order. Read more
ยง

fn try_get_u32(&mut self) -> Result<u32, TryGetError> โ“˜

Gets an unsigned 32 bit integer from self in big-endian byte order. Read more
ยง

fn try_get_u32_le(&mut self) -> Result<u32, TryGetError> โ“˜

Gets an unsigned 32 bit integer from self in little-endian byte order. Read more
ยง

fn try_get_u32_ne(&mut self) -> Result<u32, TryGetError> โ“˜

Gets an unsigned 32 bit integer from self in native-endian byte order. Read more
ยง

fn try_get_i32(&mut self) -> Result<i32, TryGetError> โ“˜

Gets a signed 32 bit integer from self in big-endian byte order. Read more
ยง

fn try_get_i32_le(&mut self) -> Result<i32, TryGetError> โ“˜

Gets a signed 32 bit integer from self in little-endian byte order. Read more
ยง

fn try_get_i32_ne(&mut self) -> Result<i32, TryGetError> โ“˜

Gets a signed 32 bit integer from self in native-endian byte order. Read more
ยง

fn try_get_u64(&mut self) -> Result<u64, TryGetError> โ“˜

Gets an unsigned 64 bit integer from self in big-endian byte order. Read more
ยง

fn try_get_u64_le(&mut self) -> Result<u64, TryGetError> โ“˜

Gets an unsigned 64 bit integer from self in little-endian byte order. Read more
ยง

fn try_get_u64_ne(&mut self) -> Result<u64, TryGetError> โ“˜

Gets an unsigned 64 bit integer from self in native-endian byte order. Read more
ยง

fn try_get_i64(&mut self) -> Result<i64, TryGetError> โ“˜

Gets a signed 64 bit integer from self in big-endian byte order. Read more
ยง

fn try_get_i64_le(&mut self) -> Result<i64, TryGetError> โ“˜

Gets a signed 64 bit integer from self in little-endian byte order. Read more
ยง

fn try_get_i64_ne(&mut self) -> Result<i64, TryGetError> โ“˜

Gets a signed 64 bit integer from self in native-endian byte order. Read more
ยง

fn try_get_u128(&mut self) -> Result<u128, TryGetError> โ“˜

Gets an unsigned 128 bit integer from self in big-endian byte order. Read more
ยง

fn try_get_u128_le(&mut self) -> Result<u128, TryGetError> โ“˜

Gets an unsigned 128 bit integer from self in little-endian byte order. Read more
ยง

fn try_get_u128_ne(&mut self) -> Result<u128, TryGetError> โ“˜

Gets an unsigned 128 bit integer from self in native-endian byte order. Read more
ยง

fn try_get_i128(&mut self) -> Result<i128, TryGetError> โ“˜

Gets a signed 128 bit integer from self in big-endian byte order. Read more
ยง

fn try_get_i128_le(&mut self) -> Result<i128, TryGetError> โ“˜

Gets a signed 128 bit integer from self in little-endian byte order. Read more
ยง

fn try_get_i128_ne(&mut self) -> Result<i128, TryGetError> โ“˜

Gets a signed 128 bit integer from self in native-endian byte order. Read more
ยง

fn try_get_uint(&mut self, nbytes: usize) -> Result<u64, TryGetError> โ“˜

Gets an unsigned n-byte integer from self in big-endian byte order. Read more
ยง

fn try_get_uint_le(&mut self, nbytes: usize) -> Result<u64, TryGetError> โ“˜

Gets an unsigned n-byte integer from self in little-endian byte order. Read more
ยง

fn try_get_uint_ne(&mut self, nbytes: usize) -> Result<u64, TryGetError> โ“˜

Gets an unsigned n-byte integer from self in native-endian byte order. Read more
ยง

fn try_get_int(&mut self, nbytes: usize) -> Result<i64, TryGetError> โ“˜

Gets a signed n-byte integer from self in big-endian byte order. Read more
ยง

fn try_get_int_le(&mut self, nbytes: usize) -> Result<i64, TryGetError> โ“˜

Gets a signed n-byte integer from self in little-endian byte order. Read more
ยง

fn try_get_int_ne(&mut self, nbytes: usize) -> Result<i64, TryGetError> โ“˜

Gets a signed n-byte integer from self in native-endian byte order. Read more
ยง

fn try_get_f32(&mut self) -> Result<f32, TryGetError> โ“˜

Gets an IEEE754 single-precision (4 bytes) floating point number from self in big-endian byte order. Read more
ยง

fn try_get_f32_le(&mut self) -> Result<f32, TryGetError> โ“˜

Gets an IEEE754 single-precision (4 bytes) floating point number from self in little-endian byte order. Read more
ยง

fn try_get_f32_ne(&mut self) -> Result<f32, TryGetError> โ“˜

Gets an IEEE754 single-precision (4 bytes) floating point number from self in native-endian byte order. Read more
ยง

fn try_get_f64(&mut self) -> Result<f64, TryGetError> โ“˜

Gets an IEEE754 double-precision (8 bytes) floating point number from self in big-endian byte order. Read more
ยง

fn try_get_f64_le(&mut self) -> Result<f64, TryGetError> โ“˜

Gets an IEEE754 double-precision (8 bytes) floating point number from self in little-endian byte order. Read more
ยง

fn try_get_f64_ne(&mut self) -> Result<f64, TryGetError> โ“˜

Gets an IEEE754 double-precision (8 bytes) floating point number from self in native-endian byte order. Read more
ยง

fn copy_to_bytes(&mut self, len: usize) -> Bytes

Consumes len bytes inside self and returns new instance of Bytes with this data. Read more
ยง

fn take(self, limit: usize) -> Take<Self>
where Self: Sized,

Creates an adaptor which will read at most limit bytes from self. Read more
ยง

fn chain<U>(self, next: U) -> Chain<Self, U>
where U: Buf, Self: Sized,

Creates an adaptor which will chain this buffer with another. Read more
ยง

fn reader(self) -> Reader<Self> โ“˜
where Self: Sized,

Creates an adaptor which implements the Read trait for self. Read more
1.75.0 ยท Sourceยง

impl<A> BufRead for VecDeque<u8, A>
where A: Allocator,

BufRead is implemented for VecDeque<u8> by reading bytes from the front of the VecDeque.

Sourceยง

fn fill_buf(&mut self) -> Result<&[u8], Error> โ“˜

Returns the contents of the โ€œfrontโ€ slice as returned by as_slices. If the contained byte slices of the VecDeque are discontiguous, multiple calls to fill_buf will be needed to read the entire content.

Sourceยง

fn consume(&mut self, amt: usize)

Tells this buffer that amt bytes have been consumed from the buffer, so they should no longer be returned in calls to read. Read more
Sourceยง

fn has_data_left(&mut self) -> Result<bool, Error> โ“˜

๐Ÿ”ฌThis is a nightly-only experimental API. (buf_read_has_data_left)
Checks if the underlying Read has any data left to be read. Read more
1.0.0 ยท Sourceยง

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, Error> โ“˜

Reads all bytes into buf until the delimiter byte or EOF is reached. Read more
1.83.0 ยท Sourceยง

fn skip_until(&mut self, byte: u8) -> Result<usize, Error> โ“˜

Skips all bytes until the delimiter byte or EOF is reached. Read more
1.0.0 ยท Sourceยง

fn read_line(&mut self, buf: &mut String) -> Result<usize, Error> โ“˜

Reads all bytes until a newline (the 0xA byte) is reached, and append them to the provided String buffer. Read more
1.0.0 ยท Sourceยง

fn split(self, byte: u8) -> Split<Self> โ“˜
where Self: Sized,

Returns an iterator over the contents of this reader split on the byte byte. Read more
1.0.0 ยท Sourceยง

fn lines(self) -> Lines<Self> โ“˜
where Self: Sized,

Returns an iterator over the lines of this reader. Read more
1.0.0 ยท Sourceยง

impl<T, A> Clone for VecDeque<T, A>
where T: Clone, A: Allocator + Clone,

Sourceยง

fn clone_from(&mut self, source: &VecDeque<T, A>)

Overwrites the contents of self with a clone of the contents of source.

This method is preferred over simply assigning source.clone() to self, as it avoids reallocation if possible.

Sourceยง

fn clone(&self) -> VecDeque<T, A>

Returns a copy of the value. Read more
Sourceยง

impl<T> ConstDefault for VecDeque<T>

Sourceยง

const DEFAULT: Self

Returns the compile-time โ€œdefault valueโ€ for a type.
Sourceยง

impl<T> DataCollection for VecDeque<T>

Sourceยง

type Element = T

The element type of the collection.
Sourceยง

fn collection_capacity(&self) -> Result<usize, NotAvailable> โ“˜

Returns the reserved capacity for elements in the collection.
Sourceยง

fn collection_len(&self) -> Result<usize, NotAvailable> โ“˜

Returns the current number of elements in the collection.
Sourceยง

fn collection_is_empty(&self) -> Result<bool, NotAvailable> โ“˜

Returns true if the collection is empty, false if itโ€™s not.
Sourceยง

fn collection_is_full(&self) -> Result<bool, NotAvailable> โ“˜

Returns true if the collection is full, false if itโ€™s not.
Sourceยง

fn collection_contains( &self, element: Self::Element, ) -> Result<bool, NotAvailable> โ“˜
where T: PartialEq,

Returns true if the collection contains the given element.
Sourceยง

fn collection_count( &self, element: &Self::Element, ) -> Result<usize, NotAvailable> โ“˜
where T: PartialEq,

Counts the number of times a given element appears in the collection.
Sourceยง

impl<T> DataDeque for VecDeque<T>

Sourceยง

fn queue_pop_back( &mut self, ) -> Result<<Self as DataCollection>::Element, NotEnoughElements> โ“˜

Remove an element from the back of the queue. Read more
Sourceยง

fn queue_push_front( &mut self, element: <Self as DataCollection>::Element, ) -> Result<(), NotEnoughSpace> โ“˜

Add an element to the front of the queue. Read more
Sourceยง

fn queue_pop_front( &mut self, ) -> Result<<Self as DataCollection>::Element, NotEnoughElements> โ“˜

Remove an element from the front of the queue (calls queue_pop). Read more
Sourceยง

fn queue_push_back( &mut self, element: <Self as DataCollection>::Element, ) -> Result<(), NotEnoughSpace> โ“˜

Remove an element from the back of the queue (calls queue_push). Read more
Sourceยง

impl<T> DataDesta for VecDeque<T>

Sourceยง

fn stack_pop_front( &mut self, ) -> Result<<Self as DataCollection>::Element, NotEnoughElements> โ“˜

Remove an element from the front of the stack.
Sourceยง

fn stack_push_front( &mut self, element: <Self as DataCollection>::Element, ) -> Result<(), NotEnoughSpace> โ“˜

Add an element to the front of the stack.
Sourceยง

fn stack_pop_back( &mut self, ) -> Result<<Self as DataCollection>::Element, NotEnoughElements> โ“˜

Remove an element from the back of the stack (calls DataStack::stack_pop).
Sourceยง

fn stack_push_back( &mut self, element: <Self as DataCollection>::Element, ) -> Result<(), NotEnoughSpace> โ“˜

Remove an element from the back of the stack (calls DataStack::stack_push).
Sourceยง

impl<T> DataQueue for VecDeque<T>

Sourceยง

fn queue_pop( &mut self, ) -> Result<<Self as DataCollection>::Element, NotEnoughElements> โ“˜

Remove an element from the (front of the) queue. Read more
Sourceยง

fn queue_push( &mut self, element: <Self as DataCollection>::Element, ) -> Result<(), NotEnoughSpace> โ“˜

Add an element to the (back of the) queue. Read more
Sourceยง

impl<T> DataStack for VecDeque<T>

Sourceยง

fn stack_pop( &mut self, ) -> Result<<Self as DataCollection>::Element, NotEnoughElements> โ“˜

Remove an element from the (back of the) stack.
Sourceยง

fn stack_push( &mut self, element: <Self as DataCollection>::Element, ) -> Result<(), NotEnoughSpace> โ“˜

Add an element to the (back of the) stack.
1.0.0 ยท Sourceยง

impl<T, A> Debug for VecDeque<T, A>
where T: Debug, A: Allocator,

Sourceยง

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

Formats the value using the given formatter. Read more
1.0.0 ยท Sourceยง

impl<T> Default for VecDeque<T>

Sourceยง

fn default() -> VecDeque<T>

Creates an empty deque.

Sourceยง

impl<'de, T> Deserialize<'de> for VecDeque<T>
where T: Deserialize<'de>,

Sourceยง

fn deserialize<D>( deserializer: D, ) -> Result<VecDeque<T>, <D as Deserializer<'de>>::Error> โ“˜
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
1.0.0 ยท Sourceยง

impl<T, A> Drop for VecDeque<T, A>
where A: Allocator,

Sourceยง

fn drop(&mut self)

Executes the destructor for this type. Read more
1.2.0 ยท Sourceยง

impl<'a, T, A> Extend<&'a T> for VecDeque<T, A>
where T: 'a + Copy, A: Allocator,

Sourceยง

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

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

fn extend_one(&mut self, _: &'a T)

๐Ÿ”ฌ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
1.0.0 ยท Sourceยง

impl<T, A> Extend<T> for VecDeque<T, A>
where A: Allocator,

Sourceยง

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

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

fn extend_one(&mut self, elem: T)

๐Ÿ”ฌ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
1.56.0 ยท Sourceยง

impl<T, const N: usize> From<[T; N]> for VecDeque<T>

Sourceยง

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

Converts a [T; N] into a VecDeque<T>.

use std::collections::VecDeque;

let deq1 = VecDeque::from([1, 2, 3, 4]);
let deq2: VecDeque<_> = [1, 2, 3, 4].into();
assert_eq!(deq1, deq2);
1.10.0 ยท Sourceยง

impl<T, A> From<Vec<T, A>> for VecDeque<T, A>
where A: Allocator,

Sourceยง

fn from(other: Vec<T, A>) -> VecDeque<T, A>

Turn a Vec<T> into a VecDeque<T>.

This conversion is guaranteed to run in O(1) time and to not re-allocate the Vecโ€™s buffer or allocate any additional memory.

1.10.0 ยท Sourceยง

impl<T, A> From<VecDeque<T, A>> for Vec<T, A>
where A: Allocator,

Sourceยง

fn from(other: VecDeque<T, A>) -> Vec<T, A> โ“˜

Turn a VecDeque<T> into a Vec<T>.

This never needs to re-allocate, but does need to do O(n) data movement if the circular buffer doesnโ€™t happen to be at the beginning of the allocation.

ยงExamples
use std::collections::VecDeque;

// This one is *O*(1).
let deque: VecDeque<_> = (1..5).collect();
let ptr = deque.as_slices().0.as_ptr();
let vec = Vec::from(deque);
assert_eq!(vec, [1, 2, 3, 4]);
assert_eq!(vec.as_ptr(), ptr);

// This one needs data rearranging.
let mut deque: VecDeque<_> = (1..5).collect();
deque.push_front(9);
deque.push_front(8);
let ptr = deque.as_slices().1.as_ptr();
let vec = Vec::from(deque);
assert_eq!(vec, [8, 9, 1, 2, 3, 4]);
assert_eq!(vec.as_ptr(), ptr);
1.0.0 ยท Sourceยง

impl<T> FromIterator<T> for VecDeque<T>

Sourceยง

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

Creates a value from an iterator. Read more
ยง

impl<T> FromParallelIterator<T> for VecDeque<T>
where T: Send,

Collects items from a parallel iterator into a vecdeque.

ยง

fn from_par_iter<I>(par_iter: I) -> VecDeque<T>
where I: IntoParallelIterator<Item = T>,

Creates an instance of the collection from the parallel iterator par_iter. Read more
1.0.0 ยท Sourceยง

impl<T, A> Hash for VecDeque<T, A>
where T: Hash, A: Allocator,

Sourceยง

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

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
1.0.0 ยท Sourceยง

impl<T, A> Index<usize> for VecDeque<T, A>
where A: Allocator,

Sourceยง

type Output = T

The returned type after indexing.
Sourceยง

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

Performs the indexing (container[index]) operation. Read more
1.0.0 ยท Sourceยง

impl<T, A> IndexMut<usize> for VecDeque<T, A>
where A: Allocator,

Sourceยง

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

Performs the mutable indexing (container[index]) operation. Read more
1.0.0 ยท Sourceยง

impl<'a, T, A> IntoIterator for &'a VecDeque<T, A>
where A: Allocator,

Sourceยง

type Item = &'a T

The type of the elements being iterated over.
Sourceยง

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Sourceยง

fn into_iter(self) -> Iter<'a, T> โ“˜

Creates an iterator from a value. Read more
1.0.0 ยท Sourceยง

impl<'a, T, A> IntoIterator for &'a mut VecDeque<T, A>
where A: Allocator,

Sourceยง

type Item = &'a mut T

The type of the elements being iterated over.
Sourceยง

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?
Sourceยง

fn into_iter(self) -> IterMut<'a, T> โ“˜

Creates an iterator from a value. Read more
1.0.0 ยท Sourceยง

impl<T, A> IntoIterator for VecDeque<T, A>
where A: Allocator,

Sourceยง

fn into_iter(self) -> IntoIter<T, A> โ“˜

Consumes 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, A>

Which kind of iterator are we turning this into?
ยง

impl<'a, T> IntoParallelIterator for &'a VecDeque<T>
where T: Sync,

ยง

type Item = &'a T

The type of item that the parallel iterator will produce.
ยง

type Iter = Iter<'a, T>

The parallel iterator type that will be created.
ยง

fn into_par_iter(self) -> <&'a VecDeque<T> as IntoParallelIterator>::Iter โ“˜

Converts self into a parallel iterator. Read more
ยง

impl<'a, T> IntoParallelIterator for &'a mut VecDeque<T>
where T: Send,

ยง

type Item = &'a mut T

The type of item that the parallel iterator will produce.
ยง

type Iter = IterMut<'a, T>

The parallel iterator type that will be created.
ยง

fn into_par_iter(self) -> <&'a mut VecDeque<T> as IntoParallelIterator>::Iter โ“˜

Converts self into a parallel iterator. Read more
ยง

impl<T> IntoParallelIterator for VecDeque<T>
where T: Send,

ยง

type Item = T

The type of item that the parallel iterator will produce.
ยง

type Iter = IntoIter<T>

The parallel iterator type that will be created.
ยง

fn into_par_iter(self) -> <VecDeque<T> as IntoParallelIterator>::Iter โ“˜

Converts self into a parallel iterator. Read more
1.0.0 ยท Sourceยง

impl<T, A> Ord for VecDeque<T, A>
where T: Ord, A: Allocator,

Sourceยง

fn cmp(&self, other: &VecDeque<T, A>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 ยท Sourceยง

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

Compares and returns the maximum of two values. Read more
1.21.0 ยท Sourceยง

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

Compares and returns the minimum of two values. Read more
1.50.0 ยท Sourceยง

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

Restrict a value to a certain interval. Read more
ยง

impl<'a, T> ParallelDrainRange for &'a mut VecDeque<T>
where T: Send,

ยง

type Iter = Drain<'a, T>

The draining parallel iterator type that will be created.
ยง

type Item = T

The type of item that the parallel iterator will produce. This is usually the same as IntoParallelIterator::Item.
ยง

fn par_drain<R>( self, range: R, ) -> <&'a mut VecDeque<T> as ParallelDrainRange>::Iter โ“˜
where R: RangeBounds<usize>,

Returns a draining parallel iterator over a range of the collection. Read more
ยง

impl<'a, T> ParallelExtend<&'a T> for VecDeque<T>
where T: 'a + Copy + Send + Sync,

Extends a deque with copied items from a parallel iterator.

ยง

fn par_extend<I>(&mut self, par_iter: I)
where I: IntoParallelIterator<Item = &'a T>,

Extends an instance of the collection with the elements drawn from the parallel iterator par_iter. Read more
ยง

impl<T> ParallelExtend<T> for VecDeque<T>
where T: Send,

Extends a deque with items from a parallel iterator.

ยง

fn par_extend<I>(&mut self, par_iter: I)
where I: IntoParallelIterator<Item = T>,

Extends an instance of the collection with the elements drawn from the parallel iterator par_iter. Read more
1.17.0 ยท Sourceยง

impl<T, U, A> PartialEq<&[U]> for VecDeque<T, A>
where A: Allocator, T: PartialEq<U>,

Sourceยง

fn eq(&self, other: &&[U]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท 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.
1.17.0 ยท Sourceยง

impl<T, U, A, const N: usize> PartialEq<&[U; N]> for VecDeque<T, A>
where A: Allocator, T: PartialEq<U>,

Sourceยง

fn eq(&self, other: &&[U; N]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท 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.
1.17.0 ยท Sourceยง

impl<T, U, A> PartialEq<&mut [U]> for VecDeque<T, A>
where A: Allocator, T: PartialEq<U>,

Sourceยง

fn eq(&self, other: &&mut [U]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท 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.
1.17.0 ยท Sourceยง

impl<T, U, A, const N: usize> PartialEq<&mut [U; N]> for VecDeque<T, A>
where A: Allocator, T: PartialEq<U>,

Sourceยง

fn eq(&self, other: &&mut [U; N]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท 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.
1.17.0 ยท Sourceยง

impl<T, U, A, const N: usize> PartialEq<[U; N]> for VecDeque<T, A>
where A: Allocator, T: PartialEq<U>,

Sourceยง

fn eq(&self, other: &[U; N]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท 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.
1.17.0 ยท Sourceยง

impl<T, U, A> PartialEq<Vec<U, A>> for VecDeque<T, A>
where A: Allocator, T: PartialEq<U>,

Sourceยง

fn eq(&self, other: &Vec<U, A>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท 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.
1.0.0 ยท Sourceยง

impl<T, A> PartialEq for VecDeque<T, A>
where T: PartialEq, A: Allocator,

Sourceยง

fn eq(&self, other: &VecDeque<T, A>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท 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.
1.0.0 ยท Sourceยง

impl<T, A> PartialOrd for VecDeque<T, A>
where T: PartialOrd, A: Allocator,

Sourceยง

fn partial_cmp(&self, other: &VecDeque<T, A>) -> Option<Ordering> โ“˜

This method returns an ordering between self and other values if one exists. Read more
1.0.0 ยท 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 ยท 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 ยท 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 ยท 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
1.63.0 ยท Sourceยง

impl<A> Read for VecDeque<u8, A>
where A: Allocator,

Read is implemented for VecDeque<u8> by consuming bytes from the front of the VecDeque.

Sourceยง

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> โ“˜

Fill buf with the contents of the โ€œfrontโ€ slice as returned by as_slices. If the contained byte slices of the VecDeque are discontiguous, multiple calls to read will be needed to read the entire content.

Sourceยง

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error> โ“˜

Reads the exact number of bytes required to fill buf. Read more
Sourceยง

fn read_buf(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error> โ“˜

๐Ÿ”ฌThis is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
Sourceยง

fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error> โ“˜

๐Ÿ”ฌThis is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
Sourceยง

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error> โ“˜

Reads all bytes until EOF in this source, placing them into buf. Read more
Sourceยง

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error> โ“˜

Reads all bytes until EOF in this source, appending them to buf. Read more
1.36.0 ยท Sourceยง

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error> โ“˜

Like read, except that it reads into a slice of buffers. Read more
Sourceยง

fn is_read_vectored(&self) -> bool

๐Ÿ”ฌThis is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
1.0.0 ยท Sourceยง

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a โ€œby referenceโ€ adaptor for this instance of Read. Read more
1.0.0 ยท Sourceยง

fn bytes(self) -> Bytes<Self> โ“˜
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 ยท Sourceยง

fn chain<R>(self, next: R) -> Chain<Self, R> โ“˜
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 ยท Sourceยง

fn take(self, limit: u64) -> Take<Self> โ“˜
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more
Sourceยง

impl<T> Serialize for VecDeque<T>
where T: Serialize,

Sourceยง

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> โ“˜
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
1.63.0 ยท Sourceยง

impl<A> Write for VecDeque<u8, A>
where A: Allocator,

Write is implemented for VecDeque<u8> by appending to the VecDeque, growing it as needed.

Sourceยง

fn write(&mut self, buf: &[u8]) -> Result<usize, Error> โ“˜

Writes a buffer into this writer, returning how many bytes were written. Read more
Sourceยง

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error> โ“˜

Like write, except that it writes from a slice of buffers. Read more
Sourceยง

fn is_write_vectored(&self) -> bool

๐Ÿ”ฌThis is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
Sourceยง

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error> โ“˜

Attempts to write an entire buffer into this writer. Read more
Sourceยง

fn flush(&mut self) -> Result<(), Error> โ“˜

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Sourceยง

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error> โ“˜

๐Ÿ”ฌThis is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 ยท Sourceยง

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error> โ“˜

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 ยท Sourceยง

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a โ€œby referenceโ€ adapter for this instance of Write. Read more
1.0.0 ยท Sourceยง

impl<T, A> Eq for VecDeque<T, A>
where T: Eq, A: Allocator,

Auto Trait Implementationsยง

ยง

impl<T, A> Freeze for VecDeque<T, A>
where A: Freeze,

ยง

impl<T, A> RefUnwindSafe for VecDeque<T, A>

ยง

impl<T, A> Send for VecDeque<T, A>
where A: Send, T: Send,

ยง

impl<T, A> Sync for VecDeque<T, A>
where A: Sync, T: Sync,

ยง

impl<T, A> Unpin for VecDeque<T, A>
where A: Unpin, T: Unpin,

ยง

impl<T, A> UnwindSafe for VecDeque<T, A>
where A: 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> ByteSized for T

Sourceยง

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
Sourceยง

const BYTE_SIZE: usize = _

The size of this type in bytes.
Sourceยง

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
Sourceยง

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
Sourceยง

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between Ptr::BYTES and BYTE_SIZE. Read more
Sourceยง

impl<T, R> Chain<R> for T
where T: ?Sized,

Sourceยง

fn chain<F>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Chain a function which takes the parameter by value.
Sourceยง

fn chain_ref<F>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Chain a function which takes the parameter by shared reference.
Sourceยง

fn chain_mut<F>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Chain a function which takes the parameter by exclusive reference.
Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

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

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
ยง

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

ยง

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
ยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

ยง

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
ยง

impl<T> ExecutableCommand for T
where T: Write + ?Sized,

ยง

fn execute(&mut self, command: impl Command) -> Result<&mut T, Error> โ“˜

Executes the given command directly.

The given command its ANSI escape code will be written and flushed onto Self.

ยงArguments
  • Command

    The command that you want to execute directly.

ยงExample
use std::io;
use crossterm::{ExecutableCommand, style::Print};

fn main() -> io::Result<()> {
     // will be executed directly
      io::stdout()
        .execute(Print("sum:\n".to_string()))?
        .execute(Print(format!("1 + 1= {} ", 1 + 1)))?;

      Ok(())

     // ==== Output ====
     // sum:
     // 1 + 1 = 2
}

Have a look over at the Command API for more details.

ยงNotes
  • In the case of UNIX and Windows 10, ANSI codes are written to the given โ€˜writerโ€™.
  • In case of Windows versions lower than 10, a direct WinAPI call will be made. The reason for this is that Windows versions lower than 10 do not support ANSI codes, and can therefore not be written to the given writer. Therefore, there is no difference between execute and queue for those old Windows versions.
Sourceยง

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

Sourceยง

fn type_id() -> TypeId

Returns the TypeId of Self. Read more
Sourceยง

fn type_of(&self) -> TypeId

Returns the TypeId of self. Read more
Sourceยง

fn type_name(&self) -> &'static str โ“˜

Returns the type name of self. Read more
Sourceยง

fn type_is<T: 'static>(&self) -> bool

Returns true if Self is of type T. Read more
Sourceยง

fn type_hash(&self) -> u64

Returns a deterministic hash of the TypeId of Self.
Sourceยง

fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64

Returns a deterministic hash of the TypeId of Self using a custom hasher.
Sourceยง

fn as_any_ref(&self) -> &dyn Any
where Self: Sized,

Upcasts &self as &dyn Any. Read more
Sourceยง

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: Sized,

Upcasts &mut self as &mut dyn Any. Read more
Sourceยง

fn as_any_box(self: Box<Self>) -> Box<dyn Any>
where Self: Sized,

Upcasts Box<self> as Box<dyn Any>. Read more
Sourceยง

fn downcast_ref<T: 'static>(&self) -> Option<&T> โ“˜

Available on crate feature unsafe_layout only.
Returns some shared reference to the inner value if it is of type T. Read more
Sourceยง

fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> โ“˜

Available on crate feature unsafe_layout only.
Returns some exclusive reference to the inner value if it is of type T. Read more
Sourceยง

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

Sourceยง

const NEEDS_DROP: bool = _

Know whether dropping values of this type matters, in compile-time.
Sourceยง

fn mem_align_of<T>() -> usize

Returns the minimum alignment of the type in bytes. Read more
Sourceยง

fn mem_align_of_val(&self) -> usize

Returns the alignment of the pointed-to value in bytes. Read more
Sourceยง

fn mem_size_of<T>() -> usize

Returns the size of a type in bytes. Read more
Sourceยง

fn mem_size_of_val(&self) -> usize

Returns the size of the pointed-to value in bytes. Read more
Sourceยง

fn mem_copy(&self) -> Self
where Self: Copy,

Bitwise-copies a value. Read more
Sourceยง

fn mem_needs_drop(&self) -> bool

Returns true if dropping values of this type matters. Read more
Sourceยง

fn mem_drop(self)
where Self: Sized,

Drops self by running its destructor. Read more
Sourceยง

fn mem_forget(self)
where Self: Sized,

Forgets about self without running its destructor. Read more
Sourceยง

fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized,

Replaces self with other, returning the previous value of self. Read more
Sourceยง

fn mem_take(&mut self) -> Self
where Self: Default,

Replaces self with its default value, returning the previous value of self. Read more
Sourceยง

fn mem_swap(&mut self, other: &mut Self)
where Self: Sized,

Swaps the value of self and other without deinitializing either one. Read more
Sourceยง

unsafe fn mem_zeroed<T>() -> T

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Sourceยง

unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Sourceยง

fn mem_as_bytes(&self) -> &[u8] โ“˜
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &[u8]. Read more
Sourceยง

fn mem_as_bytes_mut(&mut self) -> &mut [u8] โ“˜
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &mut [u8]. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

ยง

impl<S> FromSample<S> for S

ยง

fn from_sample_(s: S) -> S

Sourceยง

impl<T> Hook for T

Sourceยง

fn hook_ref<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Applies a function which takes the parameter by shared reference, and then returns the (possibly) modified owned value. Read more
Sourceยง

fn hook_mut<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Applies a function which takes the parameter by exclusive reference, and then returns the (possibly) modified owned value. Read more
ยง

impl<T> Instrument for T

ยง

fn instrument(self, span: Span) -> Instrumented<Self> โ“˜

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
ยง

fn in_current_span(self) -> Instrumented<Self> โ“˜

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self> โ“˜

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ“˜
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
ยง

impl<'data, I> IntoParallelRefIterator<'data> for I
where I: 'data + ?Sized, &'data I: IntoParallelIterator,

ยง

type Iter = <&'data I as IntoParallelIterator>::Iter

The type of the parallel iterator that will be returned.
ยง

type Item = <&'data I as IntoParallelIterator>::Item

The type of item that the parallel iterator will produce. This will typically be an &'data T reference type.
ยง

fn par_iter(&'data self) -> <I as IntoParallelRefIterator<'data>>::Iter

Converts self into a parallel iterator. Read more
ยง

impl<'data, I> IntoParallelRefMutIterator<'data> for I

ยง

type Iter = <&'data mut I as IntoParallelIterator>::Iter

The type of iterator that will be created.
ยง

type Item = <&'data mut I as IntoParallelIterator>::Item

The type of item that will be produced; this is typically an &'data mut T reference.
ยง

fn par_iter_mut( &'data mut self, ) -> <I as IntoParallelRefMutIterator<'data>>::Iter

Creates the parallel iterator from self. Read more
ยง

impl<'py, T, I> IntoPyDict<'py> for I
where T: PyDictItem<'py>, I: IntoIterator<Item = T>,

ยง

fn into_py_dict(self, py: Python<'py>) -> Result<Bound<'py, PyDict>, PyErr> โ“˜

Converts self into a PyDict object pointer. Whether pointer owned or borrowed depends on implementation.
ยง

fn into_py_dict_bound(self, py: Python<'py>) -> Bound<'py, PyDict>

๐Ÿ‘ŽDeprecated since 0.23.0: renamed to IntoPyDict::into_py_dict
Deprecated name for IntoPyDict::into_py_dict.
ยง

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

ยง

fn into_sample(self) -> T

ยง

impl<T> Pointable for T

ยง

const ALIGN: usize

The alignment of pointer.
ยง

type Init = T

The type for initializers.
ยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
ยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
ยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
ยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
ยง

impl<T> QueueableCommand for T
where T: Write + ?Sized,

ยง

fn queue(&mut self, command: impl Command) -> Result<&mut T, Error> โ“˜

Queues the given command for further execution.

Queued commands will be executed in the following cases:

  • When flush is called manually on the given type implementing io::Write.
  • The terminal will flush automatically if the buffer is full.
  • Each line is flushed in case of stdout, because it is line buffered.
ยงArguments
  • Command

    The command that you want to queue for later execution.

ยงExamples
use std::io::{self, Write};
use crossterm::{QueueableCommand, style::Print};

 fn main() -> io::Result<()> {
    let mut stdout = io::stdout();

    // `Print` will executed executed when `flush` is called.
    stdout
        .queue(Print("foo 1\n".to_string()))?
        .queue(Print("foo 2".to_string()))?;

    // some other code (no execution happening here) ...

    // when calling `flush` on `stdout`, all commands will be written to the stdout and therefore executed.
    stdout.flush()?;

    Ok(())

    // ==== Output ====
    // foo 1
    // foo 2
}

Have a look over at the Command API for more details.

ยงNotes
  • In the case of UNIX and Windows 10, ANSI codes are written to the given โ€˜writerโ€™.
  • In case of Windows versions lower than 10, a direct WinAPI call will be made. The reason for this is that Windows versions lower than 10 do not support ANSI codes, and can therefore not be written to the given writer. Therefore, there is no difference between execute and queue for those old Windows versions.
ยง

impl<R> ReadBytesExt for R
where R: Read + ?Sized,

ยง

fn read_u8(&mut self) -> Result<u8, Error> โ“˜

Reads an unsigned 8 bit integer from the underlying reader. Read more
ยง

fn read_i8(&mut self) -> Result<i8, Error> โ“˜

Reads a signed 8 bit integer from the underlying reader. Read more
ยง

fn read_u16<T>(&mut self) -> Result<u16, Error> โ“˜
where T: ByteOrder,

Reads an unsigned 16 bit integer from the underlying reader. Read more
ยง

fn read_i16<T>(&mut self) -> Result<i16, Error> โ“˜
where T: ByteOrder,

Reads a signed 16 bit integer from the underlying reader. Read more
ยง

fn read_u24<T>(&mut self) -> Result<u32, Error> โ“˜
where T: ByteOrder,

Reads an unsigned 24 bit integer from the underlying reader. Read more
ยง

fn read_i24<T>(&mut self) -> Result<i32, Error> โ“˜
where T: ByteOrder,

Reads a signed 24 bit integer from the underlying reader. Read more
ยง

fn read_u32<T>(&mut self) -> Result<u32, Error> โ“˜
where T: ByteOrder,

Reads an unsigned 32 bit integer from the underlying reader. Read more
ยง

fn read_i32<T>(&mut self) -> Result<i32, Error> โ“˜
where T: ByteOrder,

Reads a signed 32 bit integer from the underlying reader. Read more
ยง

fn read_u48<T>(&mut self) -> Result<u64, Error> โ“˜
where T: ByteOrder,

Reads an unsigned 48 bit integer from the underlying reader. Read more
ยง

fn read_i48<T>(&mut self) -> Result<i64, Error> โ“˜
where T: ByteOrder,

Reads a signed 48 bit integer from the underlying reader. Read more
ยง

fn read_u64<T>(&mut self) -> Result<u64, Error> โ“˜
where T: ByteOrder,

Reads an unsigned 64 bit integer from the underlying reader. Read more
ยง

fn read_i64<T>(&mut self) -> Result<i64, Error> โ“˜
where T: ByteOrder,

Reads a signed 64 bit integer from the underlying reader. Read more
ยง

fn read_u128<T>(&mut self) -> Result<u128, Error> โ“˜
where T: ByteOrder,

Reads an unsigned 128 bit integer from the underlying reader. Read more
ยง

fn read_i128<T>(&mut self) -> Result<i128, Error> โ“˜
where T: ByteOrder,

Reads a signed 128 bit integer from the underlying reader. Read more
ยง

fn read_uint<T>(&mut self, nbytes: usize) -> Result<u64, Error> โ“˜
where T: ByteOrder,

Reads an unsigned n-bytes integer from the underlying reader. Read more
ยง

fn read_int<T>(&mut self, nbytes: usize) -> Result<i64, Error> โ“˜
where T: ByteOrder,

Reads a signed n-bytes integer from the underlying reader. Read more
ยง

fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error> โ“˜
where T: ByteOrder,

Reads an unsigned n-bytes integer from the underlying reader.
ยง

fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error> โ“˜
where T: ByteOrder,

Reads a signed n-bytes integer from the underlying reader.
ยง

fn read_f32<T>(&mut self) -> Result<f32, Error> โ“˜
where T: ByteOrder,

Reads a IEEE754 single-precision (4 bytes) floating point number from the underlying reader. Read more
ยง

fn read_f64<T>(&mut self) -> Result<f64, Error> โ“˜
where T: ByteOrder,

Reads a IEEE754 double-precision (8 bytes) floating point number from the underlying reader. Read more
ยง

impl<W> SynchronizedUpdate for W
where W: Write + ?Sized,

ยง

fn sync_update<T>( &mut self, operations: impl FnOnce(&mut W) -> T, ) -> Result<T, Error> โ“˜

Performs a set of actions within a synchronous update.

Updates will be suspended in the terminal, the function will be executed against self, updates will be resumed, and a flush will be performed.

ยงArguments
  • Function

    A function that performs the operations that must execute in a synchronized update.

ยงExamples
use std::io;
use crossterm::{ExecutableCommand, SynchronizedUpdate, style::Print};

fn main() -> io::Result<()> {
    let mut stdout = io::stdout();

    stdout.sync_update(|stdout| {
        stdout.execute(Print("foo 1\n".to_string()))?;
        stdout.execute(Print("foo 2".to_string()))?;
        // The effects of the print command will not be present in the terminal
        // buffer, but not visible in the terminal.
        std::io::Result::Ok(())
    })?;

    // The effects of the commands will be visible.

    Ok(())

    // ==== Output ====
    // foo 1
    // foo 2
}
ยงNotes

This command is performed only using ANSI codes, and will do nothing on terminals that do not support ANSI codes, or this specific extension.

When rendering the screen of the terminal, the Emulator usually iterates through each visible grid cell and renders its current state. With applications updating the screen a at higher frequency this can cause tearing.

This mode attempts to mitigate that.

When the synchronization mode is enabled following render calls will keep rendering the last rendered state. The terminal Emulator keeps processing incoming text and sequences. When the synchronized update mode is disabled again the renderer may fetch the latest screen buffer state again, effectively avoiding the tearing effect by unintentionally rendering in the middle a of an application screen update.

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
ยง

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

ยง

fn to_sample_(self) -> U

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.
ยง

impl<T> WithSubscriber for T

ยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> โ“˜
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
ยง

fn with_current_subscriber(self) -> WithDispatch<Self> โ“˜

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
ยง

impl<W> WriteBytesExt for W
where W: Write + ?Sized,

ยง

fn write_u8(&mut self, n: u8) -> Result<(), Error> โ“˜

Writes an unsigned 8 bit integer to the underlying writer. Read more
ยง

fn write_i8(&mut self, n: i8) -> Result<(), Error> โ“˜

Writes a signed 8 bit integer to the underlying writer. Read more
ยง

fn write_u16<T>(&mut self, n: u16) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes an unsigned 16 bit integer to the underlying writer. Read more
ยง

fn write_i16<T>(&mut self, n: i16) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes a signed 16 bit integer to the underlying writer. Read more
ยง

fn write_u24<T>(&mut self, n: u32) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes an unsigned 24 bit integer to the underlying writer. Read more
ยง

fn write_i24<T>(&mut self, n: i32) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes a signed 24 bit integer to the underlying writer. Read more
ยง

fn write_u32<T>(&mut self, n: u32) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes an unsigned 32 bit integer to the underlying writer. Read more
ยง

fn write_i32<T>(&mut self, n: i32) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes a signed 32 bit integer to the underlying writer. Read more
ยง

fn write_u48<T>(&mut self, n: u64) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes an unsigned 48 bit integer to the underlying writer. Read more
ยง

fn write_i48<T>(&mut self, n: i64) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes a signed 48 bit integer to the underlying writer. Read more
ยง

fn write_u64<T>(&mut self, n: u64) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes an unsigned 64 bit integer to the underlying writer. Read more
ยง

fn write_i64<T>(&mut self, n: i64) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes a signed 64 bit integer to the underlying writer. Read more
ยง

fn write_u128<T>(&mut self, n: u128) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes an unsigned 128 bit integer to the underlying writer.
ยง

fn write_i128<T>(&mut self, n: i128) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes a signed 128 bit integer to the underlying writer.
ยง

fn write_uint<T>(&mut self, n: u64, nbytes: usize) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes an unsigned n-bytes integer to the underlying writer. Read more
ยง

fn write_int<T>(&mut self, n: i64, nbytes: usize) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes a signed n-bytes integer to the underlying writer. Read more
ยง

fn write_uint128<T>(&mut self, n: u128, nbytes: usize) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes an unsigned n-bytes integer to the underlying writer. Read more
ยง

fn write_int128<T>(&mut self, n: i128, nbytes: usize) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes a signed n-bytes integer to the underlying writer. Read more
ยง

fn write_f32<T>(&mut self, n: f32) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes a IEEE754 single-precision (4 bytes) floating point number to the underlying writer. Read more
ยง

fn write_f64<T>(&mut self, n: f64) -> Result<(), Error> โ“˜
where T: ByteOrder,

Writes a IEEE754 double-precision (8 bytes) floating point number to the underlying writer. Read more
Sourceยง

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

ยง

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

ยง

impl<T> Ungil for T
where T: Send,