Struct enso_flexer::prelude::weak_table::weak_hash_set::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

impl<T> WeakHashSet<T, RandomState> where
    T: WeakKey
[src]

pub fn new() -> WeakHashSet<T, RandomState>[src]

Creates an empty WeakHashSet.

pub fn with_capacity(capacity: usize) -> WeakHashSet<T, RandomState>[src]

Creates an empty WeakHashSet with the given capacity.

impl<T, S> WeakHashSet<T, S> where
    T: WeakKey,
    S: BuildHasher
[src]

pub fn with_hasher(hash_builder: S) -> WeakHashSet<T, S>[src]

Creates an empty WeakHashSet with the given capacity and hasher.

pub fn with_capacity_and_hasher(
    capacity: usize,
    hash_builder: S
) -> WeakHashSet<T, S>
[src]

Creates an empty WeakHashSet with the given capacity and hasher.

pub fn hasher(&self) -> &S[src]

Returns a reference to the map’s BuildHasher.

pub fn capacity(&self) -> usize[src]

Returns the number of elements the map can hold without reallocating.

pub fn remove_expired(&mut self)[src]

Removes all mappings whose keys have expired.

pub fn reserve(&mut self, additional_capacity: usize)[src]

Reserves room for additional elements.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity to the minimum allowed to hold the current number of elements.

pub fn len(&self) -> usize[src]

Returns an over-approximation of the number of elements.

pub fn is_empty(&self) -> bool[src]

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.

pub fn load_factor(&self) -> f32[src]

The proportion of buckets that are used.

This is an over-approximation because of expired elements.

pub fn clear(&mut self)[src]

Removes all associations from the map.

pub fn contains<Q>(&self, key: &Q) -> bool where
    Q: Eq + Hash + ?Sized,
    <T as WeakKey>::Key: Borrow<Q>, 
[src]

Returns true if the map contains the specified key.

pub fn get<Q>(&self, key: &Q) -> Option<<T as WeakElement>::Strong> where
    Q: Eq + Hash + ?Sized,
    <T as WeakKey>::Key: Borrow<Q>, 
[src]

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 ));

pub fn insert(&mut self, key: <T as WeakElement>::Strong) -> bool[src]

Unconditionally inserts the value, returning the old value if already present. Does not replace the key.

pub fn remove<Q>(&mut self, key: &Q) -> bool where
    Q: Eq + Hash + ?Sized,
    <T as WeakKey>::Key: Borrow<Q>, 
[src]

Removes the entry with the given key, if it exists, and returns the value.

pub fn retain<F>(&mut self, f: F) where
    F: FnMut(<T as WeakElement>::Strong) -> bool
[src]

Removes all mappings not satisfying the given predicate.

Also removes any expired mappings.

pub fn is_subset<S1>(&self, other: &WeakHashSet<T, S1>) -> bool where
    S1: BuildHasher
[src]

Is self a subset of other?

impl<T, S> WeakHashSet<T, S> where
    T: WeakKey
[src]

pub fn iter(&self) -> Iter<'_, T>

Notable traits for Iter<'a, T>

impl<'a, T> Iterator for Iter<'a, T> where
    T: WeakElement
type Item = <T as WeakElement>::Strong;
[src]

Gets an iterator over the keys and values.

pub fn drain(&mut self) -> Drain<'_, T>

Notable traits for Drain<'a, T>

impl<'a, T> Iterator for Drain<'a, T> where
    T: WeakElement
type Item = <T as WeakElement>::Strong;
[src]

Gets a draining iterator, which removes all the values but retains the storage.

Trait Implementations

impl<T, S> Clone for WeakHashSet<T, S> where
    T: Clone,
    S: Clone
[src]

pub fn clone(&self) -> WeakHashSet<T, S>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T, S> Debug for WeakHashSet<T, S> where
    T: WeakKey,
    <T as WeakElement>::Strong: Debug
[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl<T, S> Default for WeakHashSet<T, S> where
    T: WeakKey,
    S: BuildHasher + Default
[src]

pub fn default() -> WeakHashSet<T, S>[src]

Returns the “default value” for a type. Read more

impl<T, S> Extend<<T as WeakElement>::Strong> for WeakHashSet<T, S> where
    T: WeakKey,
    S: BuildHasher
[src]

pub fn extend<I>(&mut self, iter: I) where
    I: IntoIterator<Item = <T as WeakElement>::Strong>, 
[src]

Extends a collection with the contents of an iterator. Read more

fn extend_one(&mut self, item: A)[src]

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

fn extend_reserve(&mut self, additional: usize)[src]

🔬 This is a nightly-only experimental API. (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
[src]

pub fn from_iter<I>(iter: I) -> WeakHashSet<T, S> where
    I: IntoIterator<Item = <T as WeakElement>::Strong>, 
[src]

Creates a value from an iterator. Read more

impl<T, S> IntoIterator for WeakHashSet<T, S> where
    T: WeakKey
[src]

type Item = <T as WeakElement>::Strong

The type of the elements being iterated over.

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?

pub fn into_iter(self) -> <WeakHashSet<T, S> as IntoIterator>::IntoIter[src]

Creates an iterator from a value. Read more

impl<'a, T, S> IntoIterator for &'a WeakHashSet<T, S> where
    T: WeakKey
[src]

type Item = <T as WeakElement>::Strong

The type of the elements being iterated over.

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?

pub fn into_iter(self) -> <&'a WeakHashSet<T, S> as IntoIterator>::IntoIter[src]

Creates an iterator from a value. Read more

impl<T, S, S1> PartialEq<WeakHashSet<T, S1>> for WeakHashSet<T, S> where
    T: WeakKey,
    S: BuildHasher,
    S1: BuildHasher
[src]

pub fn eq(&self, other: &WeakHashSet<T, S1>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<T, S> Eq for WeakHashSet<T, S> where
    T: WeakKey,
    S: BuildHasher,
    <T as WeakKey>::Key: Eq
[src]

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

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

type RefValue = T

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> PhantomConversions for T[src]

fn phantom_into<P>() -> P where
    Self: PhantomInto<P>, 
[src]

fn phantom_from<P>() -> Self where
    P: PhantomInto<Self>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

pub fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

pub fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).

pub fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

pub fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.

impl<T> ToImpl for T[src]

fn to<P>(self) -> P where
    Self: Into<P>, 
[src]

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

type Owned = T

The resulting type after obtaining ownership.

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]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

pub fn to_ref(&self) -> &T[src]

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<T> TypeDisplay for T[src]

pub default fn type_display() -> String[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<T> Writer for T[src]

pub default fn write_by_level(&self, message: &Array)[src]

Write message using the appropriate console method.