Primitive type vector
Implementations
impl<T> [T]
pub fn len(self) -> u32
Returns the length of the vector.
pub fn push_back(self, elem: T) -> Self
Push a new element to the end of the vector, returning a new vector with a length one greater than the original unmodified vector.
pub fn push_front(self, elem: T) -> Self
Push a new element to the front of the vector, returning a new vector with a length one greater than the original unmodified vector.
pub fn pop_back(self) -> (Self, T)
Remove the last element of the vector, returning the popped vector and the element in a tuple
pub fn pop_front(self) -> (T, Self)
Remove the first element of the vector, returning the element and the popped vector in a tuple
pub fn insert(self, index: u32, elem: T) -> Self
Insert an element at a specified index, shifting all elements after it to the right
pub fn remove(self, index: u32) -> (Self, T)
Remove an element at a specified index, shifting all elements after it to the left, returning the altered vector and the removed element
pub fn append(self, other: Self) -> Self
Append each element of the other vector to the end of self.
This returns a new vector and leaves both input vectors unchanged.
pub fn as_array<let N: u32>(self) -> [T; N]
Converts this vector into an array of length N. Panics if the length of this vector is not N.
pub fn map<U, Env>(self, f: fn[Env](T) -> U) -> [U]
Apply a function to each element of the vector, returning a new vector containing the mapped elements.
pub fn mapi<U, Env>(self, f: fn[Env](u32, T) -> U) -> [U]
Apply a function to each element of the vector with its index, returning a new vector containing the mapped elements.
pub fn for_each<Env>(self, f: fn[Env](T))
Apply a function to each element of the vector
pub fn for_eachi<Env>(self, f: fn[Env](u32, T))
Apply a function to each element of the vector with its index
pub fn fold<U, Env>(self, accumulator: U, f: fn[Env](U, T) -> U) -> U
Apply a function to each element of the vector and an accumulator value,
returning the final accumulated value. This function is also sometimes
called foldl, fold_left, reduce, or inject.
pub fn reduce<Env>(self, f: fn[Env](T, T) -> T) -> T
Apply a function to each element of the vector and an accumulator value, returning the final accumulated value. Unlike fold, reduce uses the first element of the given vector as its starting accumulator value.
pub fn filter<Env>(self, predicate: fn[Env](T) -> bool) -> Self
Returns a new vector containing only elements for which the given predicate returns true.
pub fn join(self, separator: T) -> T
where
T: Append
Flatten each element in the vector into one value, separated by separator.
pub fn all<Env>(self, predicate: fn[Env](T) -> bool) -> bool
Returns true if all elements in the vector satisfy the predicate
pub fn any<Env>(self, predicate: fn[Env](T) -> bool) -> bool
Returns true if any element in the vector satisfies the predicate
A dynamically-sized view into a contiguous sequence,
[T].There are two syntactic forms for creating a vector:
[x, y, z].as_vector().[expr; N].as_vector()whereNis how many times to repeatexprin the vector.