Expand description
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).
Vectors ensure they never allocate more than isize::MAX
bytes.
§Examples
You can explicitly create a Vec
with Vec::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):
Structs§
- Drain
- A draining iterator for
Vec<T>
. - Extract
If - An iterator which uses a closure to determine if an element should be removed.
- Into
Iter - An iterator that moves out of a vector.
- Splice
- A splicing iterator for
Vec
. - Vec
- A contiguous growable array type, written as
Vec<T>
, short for ‘vector’.
Functions§
- from_
elem 👻 - from_
elem_ 👻in Experimental