Struct weak_table::WeakHashSet [−][src]
pub struct WeakHashSet<T, S = RandomState>(_);
Expand description
A hash set with weak elements, hashed on element value.
When a weak pointer expires, its mapping is lazily removed.
Implementations
Creates an empty WeakHashSet
with the given capacity.
Creates an empty WeakHashSet
with the given capacity and hasher.
Creates an empty WeakHashSet
with the given capacity and hasher.
Returns the number of elements the map can hold without reallocating.
Removes all mappings whose keys have expired.
Shrinks the capacity to the minimum allowed to hold the current number of elements.
Is the set empty?
Note that this may return false even if all keys in the set have expired, if they haven’t been collected yet.
The proportion of buckets that are used.
This is an over-approximation because of expired elements.
Returns true if the map contains the specified key.
Gets a strong reference to the given key, if found.
Examples
use weak_table::WeakHashSet;
use std::rc::{Rc, Weak};
use std::ops::Deref;
let mut set: WeakHashSet<Weak<String>> = WeakHashSet::new();
let a = Rc::new("a".to_owned());
set.insert(a.clone());
let also_a = set.get("a").unwrap();
assert!(Rc::ptr_eq( &a, &also_a ));
Unconditionally inserts the value, returning the old value if already present. Does not replace the key.
Removes the entry with the given key, if it exists, and returns the value.
Removes all mappings not satisfying the given predicate.
Also removes any expired mappings.
Is self a subset of other?
Gets an iterator over the keys and values.
Trait Implementations
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
impl<T, S> FromIterator<<T as WeakElement>::Strong> for WeakHashSet<T, S> where
T: WeakKey,
S: BuildHasher + Default,
impl<T, S> FromIterator<<T as WeakElement>::Strong> for WeakHashSet<T, S> where
T: WeakKey,
S: BuildHasher + Default,
Creates a value from an iterator. Read more
impl<T, S, S1> PartialEq<WeakHashSet<T, S1>> for WeakHashSet<T, S> where
T: WeakKey,
S: BuildHasher,
S1: BuildHasher,
impl<T, S, S1> PartialEq<WeakHashSet<T, S1>> for WeakHashSet<T, S> where
T: WeakKey,
S: BuildHasher,
S1: BuildHasher,
Auto Trait Implementations
impl<T, S> RefUnwindSafe for WeakHashSet<T, S> where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for WeakHashSet<T, S> where
S: Send,
T: Send,
impl<T, S> Sync for WeakHashSet<T, S> where
S: Sync,
T: Sync,
impl<T, S> Unpin for WeakHashSet<T, S> where
S: Unpin,
impl<T, S> UnwindSafe for WeakHashSet<T, S> where
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more