Skip to main content

VecHandle

Trait VecHandle 

Source
pub trait VecHandle<T>
where T: Clone + Send + Sync + 'static,
{ // Required methods async fn push(&self, value: T); async fn is_empty(&self) -> bool; async fn drain<R>(&self, range: R) -> Vec<T> where R: RangeBounds<usize> + Send + Sync + 'static; }
Expand description

Extension methods for Handle<Vec<T>>, exposed as VecHandle.

Required Methods§

Source

async fn push(&self, value: T)

Appends an element to the back of a collection.

§Examples
let handle = Handle::new(vec![1, 2]);
handle.push(100).await;
assert_eq!(handle.get().await, vec![1, 2, 100]);
Source

async fn is_empty(&self) -> bool

Returns true if the vector contains no elements.

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

async fn drain<R>(&self, range: R) -> Vec<T>
where R: RangeBounds<usize> + Send + Sync + 'static,

Removes the complete range from the vector in bulk, and returns it as a new vector

§Examples
let handle = Handle::new(vec![1, 2]);
let res = handle.drain(..).await;
assert_eq!(res, vec![1, 2]);
assert_eq!(handle.get().await, Vec::<i32>::new());

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<T, __V> VecHandle<T> for Handle<Vec<T>, __V>
where T: Clone + Send + Sync + 'static,

Extension methods for Handle<Vec<T>>, exposed as VecHandle.