VecDeque::pop_front
pub fn pop_front() -> Option<T> Import
Source: use collections::deque::{VecDeque}; src/collections/deque.hy Removes and returns the front value, or None when the deque is empty.
Called on a VecDeque value as value.pop_front(…).
Returns#
Option<T>
Contracts#
Checked according to --contracts (see Contracts).
ensures self.len == old(self.len) - 1 || (old(self.len) == 0 && self.len == 0)
Examples#
use collections::deque::{VecDeque};
use tests::assert;
let q: VecDeque<int> = VecDeque::new();
q.push_back(1);
q.push_back(2);
assert!((q.pop_front() ?? 0) == 1);
assert!((q.pop_front() ?? 0) == 2);
assert!(q.pop_front().is_none());
See also#
VecDeque: A double-ended queue: constant-time push and pop at both ends.VecDeque::with_capacity: Empty deque with ring capacity rounded up to the next power of two (min 8).VecDeque::new: Empty deque with default capacity 8.VecDeque::size: Returns the number of values.VecDeque::is_empty: Returnstruewhen the deque has no values.VecDeque::capacity: Returns how many values fit before the ring buffer grows.VecDeque::push_back: Addsvat the back.VecDeque::push_front: Addsvat the front.