async_std/collections/btree_map/
extend.rs

1use std::collections::BTreeMap;
2use std::pin::Pin;
3
4use crate::prelude::*;
5use crate::stream::{self, IntoStream};
6
7impl<K: Ord + Send, V: Send> stream::Extend<(K, V)> for BTreeMap<K, V> {
8    fn extend<'a, S: IntoStream<Item = (K, V)> + 'a>(
9        &'a mut self,
10        stream: S,
11    ) -> Pin<Box<dyn Future<Output = ()> + 'a + Send>>
12    where
13        <S as IntoStream>::IntoStream: Send,
14    {
15        Box::pin(stream.into_stream().for_each(move |(k, v)| {
16            self.insert(k, v);
17        }))
18    }
19}