Vec::pop
pub fn pop() -> Option<T>
Source: compiler/src/builtin_docs/prelude.hy Removes the last element and returns it, or None when the vector is empty.
Called on a Vec value as value.pop(…).
Returns#
Option<T>
Examples#
use tests::assert;
let v: Vec<int> = [1, 2];
assert!((v.pop() ?? 0) == 2);
assert!((v.pop() ?? 0) == 1);
assert!((v.pop() ?? 0) == 0);
See also#
Vec: A growable, heap-allocated vector ofTvalues.Vec::new: Creates a new, empty vector.Vec::with_capacity: Creates an empty vector with room for at leastnelements.Vec::from: Creates a vector holding a copy of the elements of the fixed arrayarr.Vec::push: Appendsxto the end of the vector.Vec::insert: Insertsxat indexi, shifting later elements one place to the right.Vec::remove: Removes the element at indexiand returns it, shifting later elements left.Vec::clear: Removes every element.