pub struct PersistentVector { /* private fields */ }Expand description
An immutable persistent vector backed by rpds::Vector.
A vector may additionally be tagged as a map entry (see
PersistentVector::map_entry): a two-element [key val] pair produced
by seq’ing a map, find, or the map-entry builtin. Map entries behave
exactly like vectors (equality, hashing, printing, indexing) — the tag
only answers map-entry? — and, as in Clojure, any derived vector
(conj, assoc, pop, …) is a plain vector again.
A vector derived by conj, assoc_nth, or pop from a GC-allocated
vector reports only its path-copied trie nodes from gc_size_extra; see
collections::share_charge for the full rule.
Implementations§
Source§impl PersistentVector
impl PersistentVector
pub fn empty() -> Self
pub fn from_vector(vector: VectorSync<Value>) -> Self
Sourcepub fn is_map_entry(&self) -> bool
pub fn is_map_entry(&self) -> bool
True only for vectors created via PersistentVector::map_entry.
pub fn count(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn nth(&self, idx: usize) -> Option<&Value>
pub fn nth(&self, idx: usize) -> Option<&Value>
Return the element at idx, or None if out of bounds.
Sourcepub fn assoc_nth(&self, idx: usize, val: Value) -> Option<Self>
pub fn assoc_nth(&self, idx: usize, val: Value) -> Option<Self>
Return a new vector with element idx replaced, or appended if idx == len.