Method in collections::list · List coil-stdlib

List::pop_front

pub fn pop_front() -> Option<T>
Import
use collections::list::{List};
Source: 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#

↑ ↓ navigate ↵ open