Struct ArrayDeque

Source
pub struct ArrayDeque<A: Array> { /* private fields */ }
Expand description

A deque structure that uses an array as backing storage.

§Example

use tinydeque::ArrayDeque;

// lots of people try to cut through the line at the DMV, and that's a dick move
// if I've ever seen one. Let's make a program to keep track
let mut dmv_line: ArrayDeque<[&'static str; 3]> = ArrayDeque::new();
dmv_line.push_back("John");
dmv_line.push_back("Thomas");
dmv_line.push_back("Larson");

// make sure the line isn't empty
assert!(!dmv_line.is_empty());
assert_eq!(dmv_line.len(), 3);

// if we push another item into the line, it will fail
assert!(dmv_line.try_push_back("Carson").is_err());

// NEXT!
assert_eq!(dmv_line.pop_front(), Some("John"));

// we have a VIP, front of the line!
dmv_line.push_front("J.J. Abrams");
assert_eq!(dmv_line.pop_front(), Some("J.J. Abrams"));

// why did J.J. Abrams get to cut in front of me in line?
// fuck this, I'm out of here
assert_eq!(dmv_line.pop_back(), Some("Larson"));

Implementations§

Source§

impl<A: Array> ArrayDeque<A>

Source

pub fn new() -> Self

Create a new ArrayDeque.

§Example
let foobar: ArrayDeque<[i32; 5]> = ArrayDeque::new();
Examples found in repository?
examples/interactive_test.rs (line 24)
23fn main() {
24    let mut test_deque: ArrayDeque<[i32; 10]> = ArrayDeque::new();
25
26    help();
27    loop {
28        print!("> ");
29        io::stdout().flush().unwrap();
30        let mut line = String::new();
31        io::stdin().read_line(&mut line).unwrap();
32        if line.is_empty() {
33            continue;
34        }
35        let command = (
36            line.remove(0),
37            if !line.is_empty() {
38                Some(line.remove(0))
39            } else {
40                None
41            },
42        );
43        if line.chars().next() == Some(' ') {
44            line.remove(0);
45            line.pop();
46        }
47        let item = if line.len() > 0 {
48            match line.parse::<i32>() {
49                Ok(s) => s,
50                Err(_) => 0,
51            }
52        } else {
53            0i32
54        };
55
56        match command {
57            ('p', Some('b')) => {
58                if let Err(reject) = test_deque.try_push_back(item) {
59                    println!("Unable to push element onto deque back: {}", reject);
60                }
61            }
62            ('p', Some('f')) => {
63                if let Err(reject) = test_deque.try_push_front(item) {
64                    println!("Unable to push element onto deque front: {}", reject);
65                }
66            }
67            ('o', Some('b')) => println!("{:?}", test_deque.pop_back()),
68            ('o', Some('f')) => println!("{:?}", test_deque.pop_front()),
69            ('c', _) => println!("Capacity: {}", ArrayDeque::<[i32; 10]>::capacity()),
70            ('l', _) => println!("Length: {}", test_deque.len()),
71            ('e', _) => println!(
72                "Deque is{} empty",
73                if test_deque.is_empty() { "" } else { " not" }
74            ),
75            ('f', _) => println!(
76                "Deque is{} full",
77                if test_deque.is_full() { "" } else { " not " }
78            ),
79            ('d', _) => println!("{:?}", &test_deque),
80            ('h', _) => help(),
81            ('q', _) => return,
82            _ => println!("Unrecognized command"),
83        }
84    }
85}
Source

pub fn capacity() -> usize

The capacity of this ArrayDeque. This is the maximum number of elements that can be stored in this ArrayDeque.

§Example
assert_eq!(ArrayDeque::<[&'static str; 8]>::capacity(), 8);
Examples found in repository?
examples/interactive_test.rs (line 69)
23fn main() {
24    let mut test_deque: ArrayDeque<[i32; 10]> = ArrayDeque::new();
25
26    help();
27    loop {
28        print!("> ");
29        io::stdout().flush().unwrap();
30        let mut line = String::new();
31        io::stdin().read_line(&mut line).unwrap();
32        if line.is_empty() {
33            continue;
34        }
35        let command = (
36            line.remove(0),
37            if !line.is_empty() {
38                Some(line.remove(0))
39            } else {
40                None
41            },
42        );
43        if line.chars().next() == Some(' ') {
44            line.remove(0);
45            line.pop();
46        }
47        let item = if line.len() > 0 {
48            match line.parse::<i32>() {
49                Ok(s) => s,
50                Err(_) => 0,
51            }
52        } else {
53            0i32
54        };
55
56        match command {
57            ('p', Some('b')) => {
58                if let Err(reject) = test_deque.try_push_back(item) {
59                    println!("Unable to push element onto deque back: {}", reject);
60                }
61            }
62            ('p', Some('f')) => {
63                if let Err(reject) = test_deque.try_push_front(item) {
64                    println!("Unable to push element onto deque front: {}", reject);
65                }
66            }
67            ('o', Some('b')) => println!("{:?}", test_deque.pop_back()),
68            ('o', Some('f')) => println!("{:?}", test_deque.pop_front()),
69            ('c', _) => println!("Capacity: {}", ArrayDeque::<[i32; 10]>::capacity()),
70            ('l', _) => println!("Length: {}", test_deque.len()),
71            ('e', _) => println!(
72                "Deque is{} empty",
73                if test_deque.is_empty() { "" } else { " not" }
74            ),
75            ('f', _) => println!(
76                "Deque is{} full",
77                if test_deque.is_full() { "" } else { " not " }
78            ),
79            ('d', _) => println!("{:?}", &test_deque),
80            ('h', _) => help(),
81            ('q', _) => return,
82            _ => println!("Unrecognized command"),
83        }
84    }
85}
Source

pub fn len(&self) -> usize

Get the length of this ArrayDeque.

§Example
use tinydeque::ArrayDeque;

// we've been hired by the Crab Patrol to find and destroy some crabs
// they said we shouldn't use Rust to do this but let's do it anyways

/// Representative of a single crab.
#[derive(Default)]
struct Crab {
    diameter: u16,
    danger_level: u16,
}

let mut crab_hitlist: ArrayDeque<[Crab; 10]> = ArrayDeque::new();
for i in 1..=10 {
    crab_hitlist.push_back(Crab { diameter: i, danger_level: 100 / i }); // small crabs are more dangerous
}

assert_eq!(crab_hitlist.len(), 10);
Examples found in repository?
examples/interactive_test.rs (line 70)
23fn main() {
24    let mut test_deque: ArrayDeque<[i32; 10]> = ArrayDeque::new();
25
26    help();
27    loop {
28        print!("> ");
29        io::stdout().flush().unwrap();
30        let mut line = String::new();
31        io::stdin().read_line(&mut line).unwrap();
32        if line.is_empty() {
33            continue;
34        }
35        let command = (
36            line.remove(0),
37            if !line.is_empty() {
38                Some(line.remove(0))
39            } else {
40                None
41            },
42        );
43        if line.chars().next() == Some(' ') {
44            line.remove(0);
45            line.pop();
46        }
47        let item = if line.len() > 0 {
48            match line.parse::<i32>() {
49                Ok(s) => s,
50                Err(_) => 0,
51            }
52        } else {
53            0i32
54        };
55
56        match command {
57            ('p', Some('b')) => {
58                if let Err(reject) = test_deque.try_push_back(item) {
59                    println!("Unable to push element onto deque back: {}", reject);
60                }
61            }
62            ('p', Some('f')) => {
63                if let Err(reject) = test_deque.try_push_front(item) {
64                    println!("Unable to push element onto deque front: {}", reject);
65                }
66            }
67            ('o', Some('b')) => println!("{:?}", test_deque.pop_back()),
68            ('o', Some('f')) => println!("{:?}", test_deque.pop_front()),
69            ('c', _) => println!("Capacity: {}", ArrayDeque::<[i32; 10]>::capacity()),
70            ('l', _) => println!("Length: {}", test_deque.len()),
71            ('e', _) => println!(
72                "Deque is{} empty",
73                if test_deque.is_empty() { "" } else { " not" }
74            ),
75            ('f', _) => println!(
76                "Deque is{} full",
77                if test_deque.is_full() { "" } else { " not " }
78            ),
79            ('d', _) => println!("{:?}", &test_deque),
80            ('h', _) => help(),
81            ('q', _) => return,
82            _ => println!("Unrecognized command"),
83        }
84    }
85}
Source

pub fn is_empty(&self) -> bool

Tell whether this ArrayDeque is empty.

§Example
let empty_deque: ArrayDeque<[(); 12]> = ArrayDeque::new();
assert!(empty_deque.is_empty());
Examples found in repository?
examples/interactive_test.rs (line 73)
23fn main() {
24    let mut test_deque: ArrayDeque<[i32; 10]> = ArrayDeque::new();
25
26    help();
27    loop {
28        print!("> ");
29        io::stdout().flush().unwrap();
30        let mut line = String::new();
31        io::stdin().read_line(&mut line).unwrap();
32        if line.is_empty() {
33            continue;
34        }
35        let command = (
36            line.remove(0),
37            if !line.is_empty() {
38                Some(line.remove(0))
39            } else {
40                None
41            },
42        );
43        if line.chars().next() == Some(' ') {
44            line.remove(0);
45            line.pop();
46        }
47        let item = if line.len() > 0 {
48            match line.parse::<i32>() {
49                Ok(s) => s,
50                Err(_) => 0,
51            }
52        } else {
53            0i32
54        };
55
56        match command {
57            ('p', Some('b')) => {
58                if let Err(reject) = test_deque.try_push_back(item) {
59                    println!("Unable to push element onto deque back: {}", reject);
60                }
61            }
62            ('p', Some('f')) => {
63                if let Err(reject) = test_deque.try_push_front(item) {
64                    println!("Unable to push element onto deque front: {}", reject);
65                }
66            }
67            ('o', Some('b')) => println!("{:?}", test_deque.pop_back()),
68            ('o', Some('f')) => println!("{:?}", test_deque.pop_front()),
69            ('c', _) => println!("Capacity: {}", ArrayDeque::<[i32; 10]>::capacity()),
70            ('l', _) => println!("Length: {}", test_deque.len()),
71            ('e', _) => println!(
72                "Deque is{} empty",
73                if test_deque.is_empty() { "" } else { " not" }
74            ),
75            ('f', _) => println!(
76                "Deque is{} full",
77                if test_deque.is_full() { "" } else { " not " }
78            ),
79            ('d', _) => println!("{:?}", &test_deque),
80            ('h', _) => help(),
81            ('q', _) => return,
82            _ => println!("Unrecognized command"),
83        }
84    }
85}
Source

pub fn is_full(&self) -> bool

Tell whether this ArrayDeque is full, or its entire capacity is filled with elements.

§Example
let full_deque: ArrayDeque<[i64; 12]> = (0i64..12).into_iter().collect();
assert!(full_deque.is_full());
Examples found in repository?
examples/interactive_test.rs (line 77)
23fn main() {
24    let mut test_deque: ArrayDeque<[i32; 10]> = ArrayDeque::new();
25
26    help();
27    loop {
28        print!("> ");
29        io::stdout().flush().unwrap();
30        let mut line = String::new();
31        io::stdin().read_line(&mut line).unwrap();
32        if line.is_empty() {
33            continue;
34        }
35        let command = (
36            line.remove(0),
37            if !line.is_empty() {
38                Some(line.remove(0))
39            } else {
40                None
41            },
42        );
43        if line.chars().next() == Some(' ') {
44            line.remove(0);
45            line.pop();
46        }
47        let item = if line.len() > 0 {
48            match line.parse::<i32>() {
49                Ok(s) => s,
50                Err(_) => 0,
51            }
52        } else {
53            0i32
54        };
55
56        match command {
57            ('p', Some('b')) => {
58                if let Err(reject) = test_deque.try_push_back(item) {
59                    println!("Unable to push element onto deque back: {}", reject);
60                }
61            }
62            ('p', Some('f')) => {
63                if let Err(reject) = test_deque.try_push_front(item) {
64                    println!("Unable to push element onto deque front: {}", reject);
65                }
66            }
67            ('o', Some('b')) => println!("{:?}", test_deque.pop_back()),
68            ('o', Some('f')) => println!("{:?}", test_deque.pop_front()),
69            ('c', _) => println!("Capacity: {}", ArrayDeque::<[i32; 10]>::capacity()),
70            ('l', _) => println!("Length: {}", test_deque.len()),
71            ('e', _) => println!(
72                "Deque is{} empty",
73                if test_deque.is_empty() { "" } else { " not" }
74            ),
75            ('f', _) => println!(
76                "Deque is{} full",
77                if test_deque.is_full() { "" } else { " not " }
78            ),
79            ('d', _) => println!("{:?}", &test_deque),
80            ('h', _) => help(),
81            ('q', _) => return,
82            _ => println!("Unrecognized command"),
83        }
84    }
85}
Source

pub fn try_push_back(&mut self, element: A::Item) -> Result<(), A::Item>

Push an element onto the back of this ArrayDeque.

§Errors

If this ArrayDeque is full, this function returns an Err with the rejected element.

§Example
use tinydeque::ArrayDeque;

// we've been hired by the United Artists of America to manage their art gallery
// because they're starving artists, they don't have the money to afford good hardware
// thus we can only store 5 paintings at a time

/// Represents a painting.
#[derive(Default)]
struct Painting {
    name: &'static str,
    rating: u8,
}

let mut painting_list: ArrayDeque<[Painting; 10]> = ArrayDeque::new();
let mut i = 0;

// we have a lot of paintings named "The Jaguar" of questionable quality
while let Ok(()) = painting_list.try_push_back(Painting { name: "The Jaguar", rating: 3 }) { i += 1; }

assert_eq!(i, 10);
Examples found in repository?
examples/interactive_test.rs (line 58)
23fn main() {
24    let mut test_deque: ArrayDeque<[i32; 10]> = ArrayDeque::new();
25
26    help();
27    loop {
28        print!("> ");
29        io::stdout().flush().unwrap();
30        let mut line = String::new();
31        io::stdin().read_line(&mut line).unwrap();
32        if line.is_empty() {
33            continue;
34        }
35        let command = (
36            line.remove(0),
37            if !line.is_empty() {
38                Some(line.remove(0))
39            } else {
40                None
41            },
42        );
43        if line.chars().next() == Some(' ') {
44            line.remove(0);
45            line.pop();
46        }
47        let item = if line.len() > 0 {
48            match line.parse::<i32>() {
49                Ok(s) => s,
50                Err(_) => 0,
51            }
52        } else {
53            0i32
54        };
55
56        match command {
57            ('p', Some('b')) => {
58                if let Err(reject) = test_deque.try_push_back(item) {
59                    println!("Unable to push element onto deque back: {}", reject);
60                }
61            }
62            ('p', Some('f')) => {
63                if let Err(reject) = test_deque.try_push_front(item) {
64                    println!("Unable to push element onto deque front: {}", reject);
65                }
66            }
67            ('o', Some('b')) => println!("{:?}", test_deque.pop_back()),
68            ('o', Some('f')) => println!("{:?}", test_deque.pop_front()),
69            ('c', _) => println!("Capacity: {}", ArrayDeque::<[i32; 10]>::capacity()),
70            ('l', _) => println!("Length: {}", test_deque.len()),
71            ('e', _) => println!(
72                "Deque is{} empty",
73                if test_deque.is_empty() { "" } else { " not" }
74            ),
75            ('f', _) => println!(
76                "Deque is{} full",
77                if test_deque.is_full() { "" } else { " not " }
78            ),
79            ('d', _) => println!("{:?}", &test_deque),
80            ('h', _) => help(),
81            ('q', _) => return,
82            _ => println!("Unrecognized command"),
83        }
84    }
85}
Source

pub fn push_back(&mut self, element: A::Item)

Push an element onto the back of this ArrayDeque.

§Panics

This function will panic if the ArrayDeque is full.

Source

pub fn try_push_front(&mut self, element: A::Item) -> Result<(), A::Item>

Push an element onto the front of this ArrayDeque.

§Errors

If this ArrayDeque is full, this function returns an Err with the rejected element.

Examples found in repository?
examples/interactive_test.rs (line 63)
23fn main() {
24    let mut test_deque: ArrayDeque<[i32; 10]> = ArrayDeque::new();
25
26    help();
27    loop {
28        print!("> ");
29        io::stdout().flush().unwrap();
30        let mut line = String::new();
31        io::stdin().read_line(&mut line).unwrap();
32        if line.is_empty() {
33            continue;
34        }
35        let command = (
36            line.remove(0),
37            if !line.is_empty() {
38                Some(line.remove(0))
39            } else {
40                None
41            },
42        );
43        if line.chars().next() == Some(' ') {
44            line.remove(0);
45            line.pop();
46        }
47        let item = if line.len() > 0 {
48            match line.parse::<i32>() {
49                Ok(s) => s,
50                Err(_) => 0,
51            }
52        } else {
53            0i32
54        };
55
56        match command {
57            ('p', Some('b')) => {
58                if let Err(reject) = test_deque.try_push_back(item) {
59                    println!("Unable to push element onto deque back: {}", reject);
60                }
61            }
62            ('p', Some('f')) => {
63                if let Err(reject) = test_deque.try_push_front(item) {
64                    println!("Unable to push element onto deque front: {}", reject);
65                }
66            }
67            ('o', Some('b')) => println!("{:?}", test_deque.pop_back()),
68            ('o', Some('f')) => println!("{:?}", test_deque.pop_front()),
69            ('c', _) => println!("Capacity: {}", ArrayDeque::<[i32; 10]>::capacity()),
70            ('l', _) => println!("Length: {}", test_deque.len()),
71            ('e', _) => println!(
72                "Deque is{} empty",
73                if test_deque.is_empty() { "" } else { " not" }
74            ),
75            ('f', _) => println!(
76                "Deque is{} full",
77                if test_deque.is_full() { "" } else { " not " }
78            ),
79            ('d', _) => println!("{:?}", &test_deque),
80            ('h', _) => help(),
81            ('q', _) => return,
82            _ => println!("Unrecognized command"),
83        }
84    }
85}
Source

pub fn push_front(&mut self, element: A::Item)

Push an element onto the front of this ArrayDeque.

§Panics

This function will panic if the ArrayDeque is full.

Source

pub fn pop_back(&mut self) -> Option<A::Item>

Pop an element from the back of this ArrayDeque.

Examples found in repository?
examples/interactive_test.rs (line 67)
23fn main() {
24    let mut test_deque: ArrayDeque<[i32; 10]> = ArrayDeque::new();
25
26    help();
27    loop {
28        print!("> ");
29        io::stdout().flush().unwrap();
30        let mut line = String::new();
31        io::stdin().read_line(&mut line).unwrap();
32        if line.is_empty() {
33            continue;
34        }
35        let command = (
36            line.remove(0),
37            if !line.is_empty() {
38                Some(line.remove(0))
39            } else {
40                None
41            },
42        );
43        if line.chars().next() == Some(' ') {
44            line.remove(0);
45            line.pop();
46        }
47        let item = if line.len() > 0 {
48            match line.parse::<i32>() {
49                Ok(s) => s,
50                Err(_) => 0,
51            }
52        } else {
53            0i32
54        };
55
56        match command {
57            ('p', Some('b')) => {
58                if let Err(reject) = test_deque.try_push_back(item) {
59                    println!("Unable to push element onto deque back: {}", reject);
60                }
61            }
62            ('p', Some('f')) => {
63                if let Err(reject) = test_deque.try_push_front(item) {
64                    println!("Unable to push element onto deque front: {}", reject);
65                }
66            }
67            ('o', Some('b')) => println!("{:?}", test_deque.pop_back()),
68            ('o', Some('f')) => println!("{:?}", test_deque.pop_front()),
69            ('c', _) => println!("Capacity: {}", ArrayDeque::<[i32; 10]>::capacity()),
70            ('l', _) => println!("Length: {}", test_deque.len()),
71            ('e', _) => println!(
72                "Deque is{} empty",
73                if test_deque.is_empty() { "" } else { " not" }
74            ),
75            ('f', _) => println!(
76                "Deque is{} full",
77                if test_deque.is_full() { "" } else { " not " }
78            ),
79            ('d', _) => println!("{:?}", &test_deque),
80            ('h', _) => help(),
81            ('q', _) => return,
82            _ => println!("Unrecognized command"),
83        }
84    }
85}
Source

pub fn pop_front(&mut self) -> Option<A::Item>

Pop an element from the front of this ArrayDeque.

Examples found in repository?
examples/interactive_test.rs (line 68)
23fn main() {
24    let mut test_deque: ArrayDeque<[i32; 10]> = ArrayDeque::new();
25
26    help();
27    loop {
28        print!("> ");
29        io::stdout().flush().unwrap();
30        let mut line = String::new();
31        io::stdin().read_line(&mut line).unwrap();
32        if line.is_empty() {
33            continue;
34        }
35        let command = (
36            line.remove(0),
37            if !line.is_empty() {
38                Some(line.remove(0))
39            } else {
40                None
41            },
42        );
43        if line.chars().next() == Some(' ') {
44            line.remove(0);
45            line.pop();
46        }
47        let item = if line.len() > 0 {
48            match line.parse::<i32>() {
49                Ok(s) => s,
50                Err(_) => 0,
51            }
52        } else {
53            0i32
54        };
55
56        match command {
57            ('p', Some('b')) => {
58                if let Err(reject) = test_deque.try_push_back(item) {
59                    println!("Unable to push element onto deque back: {}", reject);
60                }
61            }
62            ('p', Some('f')) => {
63                if let Err(reject) = test_deque.try_push_front(item) {
64                    println!("Unable to push element onto deque front: {}", reject);
65                }
66            }
67            ('o', Some('b')) => println!("{:?}", test_deque.pop_back()),
68            ('o', Some('f')) => println!("{:?}", test_deque.pop_front()),
69            ('c', _) => println!("Capacity: {}", ArrayDeque::<[i32; 10]>::capacity()),
70            ('l', _) => println!("Length: {}", test_deque.len()),
71            ('e', _) => println!(
72                "Deque is{} empty",
73                if test_deque.is_empty() { "" } else { " not" }
74            ),
75            ('f', _) => println!(
76                "Deque is{} full",
77                if test_deque.is_full() { "" } else { " not " }
78            ),
79            ('d', _) => println!("{:?}", &test_deque),
80            ('h', _) => help(),
81            ('q', _) => return,
82            _ => println!("Unrecognized command"),
83        }
84    }
85}
Source

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

Get an element at the given index.

§Example
use tinydeque::ArrayDeque;

let mut my_favorite_numbers = ArrayDeque::<[i32; 6]>::new();
my_favorite_numbers.push_back(5);
my_favorite_numbers.push_back(50);
my_favorite_numbers.push_back(33);
my_favorite_numbers.push_front(48);

assert_eq!(my_favorite_numbers.get(0), Some(&48));
assert_eq!(my_favorite_numbers.get(2), Some(&50));
assert_eq!(my_favorite_numbers.get(4), None);
Source

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

Get a mutable reference to an element at a given index.

Source

pub fn is_contiguous(&self) -> bool

Tell whether or not this ArrayDeque is contiguous.

Source

pub fn as_slices(&self) -> (&[A::Item], &[A::Item])

Get the contents of this ArrayDeque in the form of buffer slices.

Source

pub fn as_mut_slices(&mut self) -> (&mut [A::Item], &mut [A::Item])

Get the contents of this ArrayDeque in the form of mutable buffer slices.

Source

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

Truncate this ArrayDeque to a certain size.

Source

pub fn clear(&mut self)

Clear this ArrayDeque of all elements.

Source

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

Create a new iterator.

Source

pub fn append(&mut self, other: &mut Self) -> Result<(), ()>

Append another ArrayDeque onto the back of one.

§Errors

If the ArrayDeque’s contents cannot fit into this one, the Err value is returned.

Source

pub fn back(&self) -> Option<&A::Item>

Get the back item of this ArrayDeque.

Source

pub fn back_mut(&mut self) -> Option<&mut A::Item>

Get a mutable reference to the back item of this ArrayDeque.

Source

pub fn front(&self) -> Option<&A::Item>

Get the front item of this ArrayDeque.

Source

pub fn front_mut(&mut self) -> Option<&mut A::Item>

Get a mutable reference to the front item of this ArrayDeque.

Source

pub fn contains(&self, item: &A::Item) -> bool
where A::Item: PartialEq,

Tell whether or not this deque contains an element.

Trait Implementations§

Source§

impl<A: Array> Clone for ArrayDeque<A>
where A::Item: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<A: Debug + Array> Debug for ArrayDeque<A>

Source§

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

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

impl<A: Array> Default for ArrayDeque<A>

Source§

fn default() -> Self

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

impl<A: Array> Extend<<A as Array>::Item> for ArrayDeque<A>

Source§

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

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

fn extend_one(&mut self, item: A)

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

fn extend_reserve(&mut self, additional: usize)

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

impl<A: Array> FromIterator<<A as Array>::Item> for ArrayDeque<A>

Source§

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

Creates a value from an iterator. Read more

Auto Trait Implementations§

§

impl<A> Freeze for ArrayDeque<A>
where A: Freeze,

§

impl<A> RefUnwindSafe for ArrayDeque<A>
where A: RefUnwindSafe,

§

impl<A> Send for ArrayDeque<A>
where A: Send,

§

impl<A> Sync for ArrayDeque<A>
where A: Sync,

§

impl<A> Unpin for ArrayDeque<A>
where A: Unpin,

§

impl<A> UnwindSafe for ArrayDeque<A>
where A: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, 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.