pub struct Hamt<H: Hasher + Default, K: PartialEq + Eq + Hash, V> {
root: Node<K, V>,
hasher: PhantomData<H>,
}
Fields§
§root: Node<K, V>
§hasher: PhantomData<H>
Implementations§
source§impl<H: Hasher + Default, K: Clone + Eq + Hash, V: Clone> Hamt<H, K, V>
impl<H: Hasher + Default, K: Clone + Eq + Hash, V: Clone> Hamt<H, K, V>
pub fn insert(&self, k: K, v: V) -> Result<Self, InsertError>
source§impl<H: Hasher + Default, K: Eq + Hash + Clone, V: PartialEq + Clone> Hamt<H, K, V>
impl<H: Hasher + Default, K: Eq + Hash + Clone, V: PartialEq + Clone> Hamt<H, K, V>
pub fn remove_match<Q>(&self, k: &Q, v: &V) -> Result<Self, RemoveError>where K: Borrow<Q>, Q: Hash + Eq,
source§impl<H: Hasher + Default, K: Eq + Hash + Clone, V: Clone> Hamt<H, K, V>
impl<H: Hasher + Default, K: Eq + Hash + Clone, V: Clone> Hamt<H, K, V>
sourcepub fn replace(&self, k: &K, v: V) -> Result<(Self, V), ReplaceError>
pub fn replace(&self, k: &K, v: V) -> Result<(Self, V), ReplaceError>
Replace the element at the key by the v and return the new tree and the old value.
sourcepub fn replace_with<F>(&self, k: &K, f: F) -> Result<Self, ReplaceError>where
F: FnOnce(&V) -> V,
pub fn replace_with<F>(&self, k: &K, f: F) -> Result<Self, ReplaceError>where F: FnOnce(&V) -> V,
Replace the element at the key by the v and return the new tree and the old value.
source§impl<H: Hasher + Default, K: Eq + Hash + Clone, V: Clone> Hamt<H, K, V>
impl<H: Hasher + Default, K: Eq + Hash + Clone, V: Clone> Hamt<H, K, V>
sourcepub fn update<F, U>(&self, k: &K, f: F) -> Result<Self, UpdateError<U>>where
F: FnOnce(&V) -> Result<Option<V>, U>,
U: Error + Debug + 'static,
pub fn update<F, U>(&self, k: &K, f: F) -> Result<Self, UpdateError<U>>where F: FnOnce(&V) -> Result<Option<V>, U>, U: Error + Debug + 'static,
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
sourcepub fn insert_or_update<F, E>(&self, k: K, v: V, f: F) -> Result<Self, E>where
F: FnOnce(&V) -> Result<Option<V>, E>,
V: Clone,
E: Error + Debug + 'static,
pub fn insert_or_update<F, E>(&self, k: K, v: V, f: F) -> Result<Self, E>where F: FnOnce(&V) -> Result<Option<V>, E>, V: Clone, E: Error + Debug + 'static,
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
sourcepub fn insert_or_update_simple<F>(&self, k: K, v: V, f: F) -> Selfwhere
F: for<'a> FnOnce(&'a V) -> Option<V>,
V: Clone,
pub fn insert_or_update_simple<F>(&self, k: K, v: V, f: F) -> Selfwhere F: for<'a> FnOnce(&'a V) -> Option<V>, V: Clone,
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