List::pop_front
pub fn pop_front() -> Option<T> Import
Source: use collections::list::{List}; src/collections/list.hy Removes and returns the front value, or None when the list is empty. Constant time.
Called on a List 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::list::{List};
use tests::assert;
let xs: List<int> = List::new();
xs.push_front(7);
assert!((xs.pop_front() ?? 0) == 7);
assert!(xs.pop_front().is_none());
See also#
List: A singly-linked list with constant-time push and pop at the front.List::new: Creates an empty list.List::size: Returns the number of values.List::is_empty: Returnstruewhen the list has no values.List::push_front: Addsvat the front.List::push_back: Addsvat the back.List::peek_front: Returns the front value without removing it, orNonewhen the list is empty.List::pop_back: Removes and returns the back value, orNonewhen the list is empty.