Vec::from
pub static fn from([T; N] arr) -> Vec<T>
Source: compiler/src/builtin_docs/prelude.hy Creates a vector holding a copy of the elements of the fixed array arr.
Parameters#
| Name | Type |
|---|---|
arr | [T; N] |
Returns#
Vec<T>
Examples#
use tests::assert;
let v = Vec::from([1, 2, 3]);
v.push(4);
assert!(v.len() == 4);
assert!(v[3] == 4);
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::push: Appendsxto the end of the vector.Vec::pop: Removes the last element and returns it, orNonewhen the vector is empty.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.