Skip to main content

HashSetHandle

Trait HashSetHandle 

Source
pub trait HashSetHandle<K>
where K: Clone + Eq + Hash + Send + Sync + 'static,
{ // Required methods async fn insert(&self, val: K) -> bool; async fn is_empty(&self) -> bool; }
Expand description

Extension methods for Handle<HashSet<K>>, exposed as HashSetHandle.

Required Methods§

Source

async fn insert(&self, val: K) -> bool

Adds a value to the set. Returns whether the value was newly inserted. That is:

  • If the set did not previously contain this value, true is returned.
  • If the set already contained this value, false is returned, and the set is not modified: original value is not replaced, and the value passed as argument is dropped.
§Examples
let handle = Handle::new(HashSet::new());
let res = handle.insert(10).await;
assert!(res);

let res = handle.insert(10).await;
assert!(!res);
Source

async fn is_empty(&self) -> bool

Returns true if the set contains no elements.

§Examples
let handle = Handle::new(HashSet::<i32>::new());
assert!(handle.is_empty().await);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<K, __V> HashSetHandle<K> for Handle<HashSet<K>, __V>
where K: Clone + Eq + Hash + Send + Sync + 'static,

Extension methods for Handle<HashSet<K>>, exposed as HashSetHandle.