pub enum MapValue {
Array(GcPtr<PersistentArrayMap>),
Hash(GcPtr<PersistentHashMap>),
Sorted(GcPtr<SortedMap>),
}Expand description
A map value: either a small array-map or a HAMT-based hash-map.
Variants§
Implementations§
Source§impl MapValue
impl MapValue
pub fn empty() -> Self
Sourcepub fn from_pairs(pairs: Vec<(Value, Value)>) -> Self
pub fn from_pairs(pairs: Vec<(Value, Value)>) -> Self
Build a map from pre-evaluated key-value pairs.
Chooses the optimal representation based on size: ArrayMap for small
maps (≤8 entries), HashTrieMap for larger ones. This avoids N
intermediate allocations that empty() + assoc + assoc + ... would
create.
Sourcepub fn from_flat_entries(entries: Vec<Value>) -> Self
pub fn from_flat_entries(entries: Vec<Value>) -> Self
Build a map from a flat evaluated entries vector [k0, v0, k1, v1, ...].
Similar to from_pairs but takes flat key-value entries. Handles
duplicate keys (last wins via assoc). Avoids intermediate allocations.
pub fn get(&self, key: &Value) -> Option<Value>
pub fn count(&self) -> usize
pub fn assoc(&self, k: Value, v: Value) -> Self
pub fn dissoc(&self, key: &Value) -> Self
pub fn contains_key(&self, key: &Value) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for MapValue
impl !Send for MapValue
impl !Sync for MapValue
impl !UnwindSafe for MapValue
impl Freeze for MapValue
impl Unpin for MapValue
impl UnsafeUnpin for MapValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more