Skip to main content

MapLike

Trait MapLike 

Source
pub trait MapLike: Sized {
    // Required methods
    fn new() -> Self;
    fn get(&self, key: &u64) -> Option<&(NanValue, NanValue)>;
    fn insert(&self, key: u64, value: (NanValue, NanValue)) -> Self;
    fn rewrite_values_mut(&mut self, f: impl FnMut(&mut (NanValue, NanValue)));
    fn len(&self) -> usize;
    fn iter(&self) -> impl Iterator<Item = (&u64, &(NanValue, NanValue))>;
    fn values(&self) -> impl Iterator<Item = &(NanValue, NanValue)>;

    // Provided methods
    fn insert_owned(self, key: u64, value: (NanValue, NanValue)) -> Self { ... }
    fn is_empty(&self) -> bool { ... }
}
Expand description

Trait abstracting the persistent-map operations needed by the arena.

Implementors provide a hash-keyed map from u64 to (NanValue, NanValue).

Required Methods§

Source

fn new() -> Self

Source

fn get(&self, key: &u64) -> Option<&(NanValue, NanValue)>

Source

fn insert(&self, key: u64, value: (NanValue, NanValue)) -> Self

Source

fn rewrite_values_mut(&mut self, f: impl FnMut(&mut (NanValue, NanValue)))

Rewrite NanValue pairs in place — avoids rebuilding the hash table. Uses copy-on-write: O(1) when sole owner, O(n) clone when shared.

Source

fn len(&self) -> usize

Source

fn iter(&self) -> impl Iterator<Item = (&u64, &(NanValue, NanValue))>

Source

fn values(&self) -> impl Iterator<Item = &(NanValue, NanValue)>

Provided Methods§

Source

fn insert_owned(self, key: u64, value: (NanValue, NanValue)) -> Self

Insert with owned self — avoids clone when sole owner.

Source

fn is_empty(&self) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl MapLike for AverMap<u64, (NanValue, NanValue)>

Available on crate feature runtime only.
Source§

fn new() -> AverMap<u64, (NanValue, NanValue)>

Source§

fn get(&self, key: &u64) -> Option<&(NanValue, NanValue)>

Source§

fn insert( &self, key: u64, value: (NanValue, NanValue), ) -> AverMap<u64, (NanValue, NanValue)>

Source§

fn insert_owned( self, key: u64, value: (NanValue, NanValue), ) -> AverMap<u64, (NanValue, NanValue)>

Source§

fn rewrite_values_mut(&mut self, f: impl FnMut(&mut (NanValue, NanValue)))

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn iter(&self) -> impl Iterator<Item = (&u64, &(NanValue, NanValue))>

Source§

fn values(&self) -> impl Iterator<Item = &(NanValue, NanValue)>

Implementors§