Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/collections/vector"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
block |
alloc/block |
vector.dodo |
error |
alloc/error |
vector.dodo |
layout |
alloc/layout |
vector.dodo |
mem |
core/mem |
vector.dodo |
ptr |
core/ptr |
vector.dodo |
Vector
Struct · Source
A is an owned allocator capability: allocate(&self,&Layout)->Block!AllocError, unsafe deallocate(&self,Block). It may retain checked backing dependencies.
pub struct Vector<T, A> {
// Private implementation fields omitted.
}
Vector.next
Function · Source
Cursor starts at zero. Each call yields one logical element.
pub fn next(&self, cursor: &mut usize) -> Option<&T> from(self)
Vector.len
Function · Source
pub fn len(&self) -> usize
Vector.capacity
Function · Source
pub fn capacity(&self) -> usize
Vector.is_empty
Function · Source
pub fn is_empty(&self) -> bool
Vector.as_slice
Function · Source
pub fn as_slice(&self) -> &[T]
Vector.as_mut_slice
Function · Source
pub fn as_mut_slice(&mut self) -> &mut[T] requires_plain(T)
Vector.get
Function · Source
pub fn get(&self, index: usize) -> Option<&T>
Vector.get_mut
Function · Source
pub fn get_mut(&mut self, index: usize) -> Option<&mut T> requires_plain(T)
Vector.try_update
Function · Source
Scoped mutation: M.apply(&mut T)->void!E may edit an owned payload, but cannot retain its temporary borrow or add new stored dependencies. Restore the occupied slot before propagating errors; edits are not rolled back. Missing indices return ok(false) without calling the mutation.
pub fn try_update<M, E>(&mut self, index: usize, mutation: &mut M) -> bool!E requires_plain(E)
Vector.reserve
Function · Source
Geometric growth; failure preserves all existing values and capacity.
pub fn reserve(&mut self, additional: usize) -> void!error.AllocError
Vector.push
Function · Source
pub fn push(&mut self, value: T) -> void!error.AllocError stores(self, value)
Vector.pop
Function · Source
pub fn pop(&mut self) -> Option<T> from(self.stored)
Vector.insert
Function · Source
Out-of-range is represented by UnsupportedLayout; no mutation on error.
pub fn insert(&mut self, index: usize, value: T) -> void!error.AllocError stores(self, value)
Vector.remove
Function · Source
pub fn remove(&mut self, index: usize) -> Option<T> from(self.stored)
Vector.swap_remove
Function · Source
pub fn swap_remove(&mut self, index: usize) -> Option<T> from(self.stored)
Vector.replace
Function · Source
Invalid index destroys the replacement and returns none.
pub fn replace(&mut self, index: usize, value: T) -> Option<T> from(self.stored) stores(self, value)
Vector.swap
Function · Source
pub fn swap(&mut self, a: usize, b: usize) -> bool
Vector.clear
Function · Source
pub fn clear(&mut self)
new
Function · Source
SAFETY: A must keep all allocations unique, aligned, valid until deallocate, and alive while the capability lives. No allocation occurs in new.
pub unsafe fn new<T, A>(allocator: A) -> Vector<T, A> from(allocator)
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.