A contiguous growable array type with heap-allocated contents, written Vec<T>
.
Vectors have O(1)
indexing, amortized O(1)
push (to the end) and O(1)
pop (from the end).
You can explicitly create a Vec<T>
with new
:
...or by using the vec!
macro:
You can push
values onto the end of a vector (which will grow the vector as needed):
Popping values works in much the same way:
Vectors also support indexing (through the Index
and IndexMut
traits):
Drain |
A draining iterator for |
IntoIter |
An iterator that moves out of a vector. |
Splice |
A splicing iterator for |
Vec |
A contiguous growable array type, written |
DrainFilter |
Experimental An iterator produced by calling |
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/vec/index.html