pub trait Extend<A> {
fn extend<'a, T: IntoStream<Item = A> + 'a>(
&'a mut self,
stream: T
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<T as IntoStream>::IntoStream: Send;
}
Expand description
Extends a collection with the contents of a stream.
Streams produce a series of values asynchronously, and collections can also be thought of as a
series of values. The Extend
trait bridges this gap, allowing you to extend a collection
asynchronously by including the contents of that stream. When extending a collection with an
already existing key, that entry is updated or, in the case of collections that permit multiple
entries with equal keys, that entry is inserted.
Examples
use async_std::prelude::*;
use async_std::stream;
let mut v: Vec<usize> = vec![1, 2];
let s = stream::repeat(3usize).take(3);
stream::Extend::extend(&mut v, s).await;
assert_eq!(v, vec![1, 2, 3, 3, 3]);
Required methods
fn extend<'a, T: IntoStream<Item = A> + 'a>(
&'a mut self,
stream: T
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<T as IntoStream>::IntoStream: Send,
fn extend<'a, T: IntoStream<Item = A> + 'a>(
&'a mut self,
stream: T
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<T as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Extends a collection with the contents of a stream.
Implementations on Foreign Types
sourceimpl Extend<()> for ()
impl Extend<()> for ()
fn extend<'a, S: IntoStream<Item = ()> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl<T: Send> Extend<T> for Vec<T>
impl<T: Send> Extend<T> for Vec<T>
fn extend<'a, S: IntoStream<Item = T> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl Extend<char> for String
impl Extend<char> for String
fn extend<'a, S: IntoStream<Item = char> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl<'b> Extend<&'b char> for String
impl<'b> Extend<&'b char> for String
fn extend<'a, S: IntoStream<Item = &'b char> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl<'b> Extend<&'b str> for String
impl<'b> Extend<&'b str> for String
fn extend<'a, S: IntoStream<Item = &'b str> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl Extend<String> for String
impl Extend<String> for String
fn extend<'a, S: IntoStream<Item = String> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl<'b> Extend<Cow<'b, str>> for String
impl<'b> Extend<Cow<'b, str>> for String
fn extend<'a, S: IntoStream<Item = Cow<'b, str>> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl<T: Ord + Send> Extend<T> for BinaryHeap<T>
impl<T: Ord + Send> Extend<T> for BinaryHeap<T>
fn extend<'a, S: IntoStream<Item = T> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl<K: Ord + Send, V: Send> Extend<(K, V)> for BTreeMap<K, V>
impl<K: Ord + Send, V: Send> Extend<(K, V)> for BTreeMap<K, V>
fn extend<'a, S: IntoStream<Item = (K, V)> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl<T: Ord + Send> Extend<T> for BTreeSet<T>
impl<T: Ord + Send> Extend<T> for BTreeSet<T>
fn extend<'a, S: IntoStream<Item = T> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl<K, V, H> Extend<(K, V)> for HashMap<K, V, H> where
K: Eq + Hash + Send,
V: Send,
H: BuildHasher + Default + Send,
impl<K, V, H> Extend<(K, V)> for HashMap<K, V, H> where
K: Eq + Hash + Send,
V: Send,
H: BuildHasher + Default + Send,
fn extend<'a, S: IntoStream<Item = (K, V)> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl<T, H> Extend<T> for HashSet<T, H> where
T: Eq + Hash + Send,
H: BuildHasher + Default + Send,
impl<T, H> Extend<T> for HashSet<T, H> where
T: Eq + Hash + Send,
H: BuildHasher + Default + Send,
fn extend<'a, S: IntoStream<Item = T> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl<T: Send> Extend<T> for LinkedList<T>
impl<T: Send> Extend<T> for LinkedList<T>
fn extend<'a, S: IntoStream<Item = T> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
sourceimpl<T: Send> Extend<T> for VecDeque<T>
impl<T: Send> Extend<T> for VecDeque<T>
fn extend<'a, S: IntoStream<Item = T> + 'a>(
&'a mut self,
stream: S
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
<S as IntoStream>::IntoStream: Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;