[][src]Trait async_std::stream::Extend

pub trait Extend<A> {
    fn extend<'a, T: IntoStream<Item = A> + 'a>(
        &'a mut self,
        stream: T
    ) -> Pin<Box<dyn Future<Output = ()> + 'a>>
    where
        A: 'a
; }
This is supported on unstable only.

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

Important traits for Pin<P>
fn extend<'a, T: IntoStream<Item = A> + 'a>(
    &'a mut self,
    stream: T
) -> Pin<Box<dyn Future<Output = ()> + 'a>> where
    A: 'a, 

This is supported on unstable only.

Extends a collection with the contents of a stream.

Loading content...

Implementations on Foreign Types

impl Extend<()> for ()[src]

impl<T> Extend<T> for Vec<T>[src]

impl Extend<char> for String[src]

impl<'b> Extend<&'b char> for String[src]

impl<'b> Extend<&'b str> for String[src]

impl Extend<String> for String[src]

impl<'b> Extend<Cow<'b, str>> for String[src]

impl<T: Ord> Extend<T> for BinaryHeap<T>[src]

impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V>[src]

impl<T: Ord> Extend<T> for BTreeSet<T>[src]

impl<K, V, H> Extend<(K, V)> for HashMap<K, V, H> where
    K: Eq + Hash,
    H: BuildHasher + Default
[src]

impl<T, H> Extend<T> for HashSet<T, H> where
    T: Eq + Hash,
    H: BuildHasher + Default
[src]

impl<T> Extend<T> for LinkedList<T>[src]

impl<T> Extend<T> for VecDeque<T>[src]

Loading content...

Implementors

impl<P: AsRef<Path>> Extend<P> for PathBuf[src]

Loading content...