[][src]Struct hamst::HamtMut

pub struct HamtMut<K, V, H> { /* fields omitted */ }

Mutable HAMT data structure

This is created after a thaw of an immutable HAMT, and right after the creation, all the node are still shared with the immutable HAMT.

Once modification happens, then each nodes from root to leaf will be modified and kept in an efficient mutable format until freezing.

Implementations

impl<H: Hasher + Default, K: Clone + Eq + Hash, V: Clone> HamtMut<K, V, H>[src]

pub fn new() -> Self[src]

Create a new empty mutable HAMT

impl<H, K, V> HamtMut<K, V, H>[src]

pub fn freeze(self) -> Hamt<K, V, H>[src]

Freeze the mutable HAMT back into an immutable HAMT

This recursively freeze all the mutable nodes

impl<H: Hasher + Default, K: Clone + Eq + Hash, V: Clone> HamtMut<K, V, H>[src]

pub fn insert(&mut self, k: K, v: V) -> Result<(), InsertError>[src]

Insert a new key into the HAMT

If the key already exists, then an InsertError is returned.

To simulaneously manipulate a key, either to insert or update, use 'insert_or_update'

impl<H: Hasher + Default, K: Eq + Hash + Clone, V: PartialEq + Clone> HamtMut<K, V, H>[src]

pub fn remove_match(&mut self, k: &K, v: &V) -> Result<(), RemoveError>[src]

Remove a key from the HAMT, if it also matching the value V

If the key doesn't exist, then RemoveError::KeyNotFound will be returned and otherwise if the key exists but the value doesn't match, RemoveError::ValueNotMatching will be returned.

impl<H: Hasher + Default, K: Clone + Eq + Hash, V: Clone> HamtMut<K, V, H>[src]

pub fn remove(&mut self, k: &K) -> Result<(), RemoveError>[src]

Remove a key from the HAMT

If the key doesn't exist, then RemoveError::KeyNotFound will be returned

impl<H: Hasher + Default, K: Eq + Hash + Clone, V: Clone> HamtMut<K, V, H>[src]

pub fn replace(&mut self, k: &K, v: V) -> Result<V, ReplaceError>[src]

Replace the element at the key by the v and return the new tree and the old value.

pub fn replace_with<F>(&mut self, k: &K, f: F) -> Result<(), ReplaceError> where
    F: FnOnce(&V) -> V, 
[src]

Replace the element at the key by the v and return the new tree and the old value.

impl<H: Hasher + Default, K: Eq + Hash + Clone, V: Clone> HamtMut<K, V, H>[src]

pub fn update<F, U>(&mut self, k: &K, f: F) -> Result<(), UpdateError<U>> where
    F: FnOnce(&V) -> Result<Option<V>, U>, 
[src]

Update the element at the key K.

If the closure F in parameter returns None, then the key is deleted.

If the key is not present then UpdateError::KeyNotFound is returned

pub fn insert_or_update<F, E>(&mut self, k: K, v: V, f: F) -> Result<(), E> where
    F: FnOnce(&V) -> Result<Option<V>, E>,
    V: Clone
[src]

Update or insert the element at the key K

If the element is not present, then V is added, otherwise the closure F is apply to the found element. If the closure returns None, then the key is deleted

pub fn insert_or_update_simple<F>(&mut self, k: K, v: V, f: F) where
    F: for<'a> FnOnce(&'a V) -> Option<V>,
    V: Clone
[src]

Update or insert the element at the key K

If the element is not present, then V is added, otherwise the closure F is apply to the found element. If the closure returns None, then the key is deleted.

This is similar to 'insert_or_update' except the closure shouldn't be failing

Trait Implementations

impl<H, K, V> Clone for HamtMut<K, V, H>[src]

impl<'a, H, K, V> From<&'a Hamt<K, V, H>> for HamtMut<K, V, H>[src]

impl<H: Default + Hasher, K: Eq + Hash + Clone, V: Clone> FromIterator<(K, V)> for HamtMut<K, V, H>[src]

Auto Trait Implementations

impl<K, V, H> RefUnwindSafe for HamtMut<K, V, H> where
    H: RefUnwindSafe,
    K: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V, H> Send for HamtMut<K, V, H> where
    H: Send,
    K: Send + Sync,
    V: Send + Sync

impl<K, V, H> Sync for HamtMut<K, V, H> where
    H: Sync,
    K: Send + Sync,
    V: Send + Sync

impl<K, V, H> Unpin for HamtMut<K, V, H> where
    H: Unpin

impl<K, V, H> UnwindSafe for HamtMut<K, V, H> where
    H: UnwindSafe,
    K: RefUnwindSafe,
    V: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.