Struct hash_trie::HashTrieSet [−][src]
Expand description
HashTrieSet
implements a hash set using a hash array mapped trie (HAMT).
Example Usage
use hash_trie::HashTrieSet; use std::{borrow::Cow, collections::hash_map::DefaultHasher}; let mut hash_set: HashTrieSet<u64, String, DefaultHasher> = HashTrieSet::new(); let hello_world: String = "Hello, world!".into(); hash_set = hash_set.insert(Cow::Borrowed(&hello_world)).unwrap(); // Inserting an already-inserted value returns a reference to the value in the set. assert_eq!(*hash_set.insert(Cow::Borrowed(&hello_world)).unwrap_err(), hello_world); assert_eq!(*hash_set.find(&hello_world).unwrap(), hello_world); match hash_set.remove(&hello_world) { Ok((mutated, reference)) => { // Removing a value returns a reference to the value // in the set in addition to the mutated set. println!("Value stored in hash_set: {}", reference); hash_set = mutated; }, Err(_) => panic!(), }
Implementations
impl<B: Bits, V: Value, H: HasherBv<B, V>> HashTrieSet<B, V, H>
[src]
impl<B: Bits, V: Value, H: HasherBv<B, V>> HashTrieSet<B, V, H>
[src]pub fn find(&self, value: &V) -> Result<&V, HashTrieError>
[src]
pub fn find(&self, value: &V) -> Result<&V, HashTrieError>
[src]Search the HashTrieSet for the given value and return a reference if found, or HashTrieError::NotFound
if not found.
pub fn insert(&self, value: Cow<'_, V>) -> Result<Self, &V>
[src]
pub fn insert(&self, value: Cow<'_, V>) -> Result<Self, &V>
[src]Search the HashTrieSet for the spot to insert the value and return a mutated set, or a reference to the existing value if found.
pub fn remove(&self, value: &V) -> Result<(Self, &V), HashTrieError>
[src]
pub fn remove(&self, value: &V) -> Result<(Self, &V), HashTrieError>
[src]Search the HashTrieSet for the given value to remove and return a mutated set, or HashTrieError::NotFound
if not found.
Trait Implementations
impl<B: Clone + Bits, V: Clone + Value, H: Clone + HasherBv<B, V>> Clone for HashTrieSet<B, V, H>
[src]
impl<B: Clone + Bits, V: Clone + Value, H: Clone + HasherBv<B, V>> Clone for HashTrieSet<B, V, H>
[src]fn clone(&self) -> HashTrieSet<B, V, H>
[src]
fn clone(&self) -> HashTrieSet<B, V, H>
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl<B, V, H> !Send for HashTrieSet<B, V, H>
impl<B, V, H> !Sync for HashTrieSet<B, V, H>
impl<B, V, H> Unpin for HashTrieSet<B, V, H>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more