Vec

Associated Functions for the Vec type

Built-in associated functions for the Vec<T, N> type.

A dynamic-length vector with fixed capacity. Elements can be added and removed up to the capacity limit.


Adding Elements

push

fn push(mut self, element: T)

Appends an element to the end of the vector.

prepend

fn prepend(mut self, element: T)

Inserts an element at the beginning of the vector.

insert

fn insert(mut self, index: Int, element: T)

Inserts an element at the specified index, shifting subsequent elements to the right.

extend

fn extend(mut self, other_vec: Vec<T>)

Extends the vector with elements from another vector.


Removing Elements

pop

fn pop(mut self) -> T

Removes and returns the last element from the vector.

remove

fn remove(mut self, index: Int)

Removes the element at the specified index, shifting subsequent elements to the left.


Slicing

slice

fn slice(self, start: Int, end: Int) -> Vec<T>

Returns a slice view of the vector from start (inclusive) to end (exclusive).


For additional associated functions like len, is_empty, filter, find, etc., see Sequential associated functions.