std::vector
std::vector provides a generic, growable owning container Vector(T) used
widely throughout std::.
Full reference: vector.
Notes#
- Supported forms + design: a usable subset is implemented in
std/vector.slk. - Full reference: vector
Importing#
import std::vector;
Examples#
Example: push/pop#
import std::vector;
type Vec = std::vector::Vector(int);
fn main () -> int {
match (Vec.init(4)) {
Ok(vec) => {
let mut v: Vec = vec;
v.push(1);
v.push(2);
let x: int = v.pop() ?? 0;
v.drop();
return x;
},
Err(_) => {
return 0;
},
}
}
See also#
- Full reference: vector
- Slices and iterators: arrays, interfaces
Source repository · Edit this page · View Markdown