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, V> 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>> {
12 Box::pin(stream.into_stream().for_each(move |(k, v)| {
13 self.insert(k, v);
14 }))
15 }
16}