Type Definition coca::collections::AllocDeque
source · [−]pub type AllocDeque<T, I = usize> = Deque<T, AllocStorage<ArrayLayout<T>>, I>;
This is supported on crate feature
alloc
only.Expand description
A deque using a heap-allocated slice for storage.
Note that this still has a fixed capacity, and will never reallocate.
Examples
let mut deque = coca::collections::AllocDeque::<char>::with_capacity(4);
deque.push_front('b');
deque.push_front('a');
deque.push_back('c');
deque.push_back('d');
assert_eq!(deque, &['a', 'b', 'c', 'd']);
assert_eq!(deque.try_push_back('e'), Err('e'));
Implementations
sourceimpl<T: Copy, I: Capacity> AllocDeque<T, I>
impl<T: Copy, I: Capacity> AllocDeque<T, I>
sourcepub fn with_capacity(capacity: I) -> Self
pub fn with_capacity(capacity: I) -> Self
Creates an empty AllocDeque
with the specified capacity.
Panics
Panics if capacity
cannot be represented by the a usize
.