Remove unnecessary trait bound on FlatMap (#651)

* Remove unnecessary trait bound on FlatMap

* test: upgrade test code
pull/672/head
nasa 5 years ago committed by Stjepan Glavina
parent 98d45f4be1
commit 0ed0d63094

@ -41,7 +41,6 @@ where
impl<S, U, F> Stream for FlatMap<S, U, F>
where
S: Stream,
S::Item: IntoStream<IntoStream = U, Item = U::Item>,
U: Stream,
F: FnMut(S::Item) -> U,
{

@ -791,18 +791,22 @@ extension_trait! {
# async_std::task::block_on(async {
use async_std::prelude::*;
use async_std::stream::IntoStream;
use async_std::stream;
let inner1 = stream::from_iter(vec![1,2,3]);
let inner2 = stream::from_iter(vec![4,5,6]);
let words = stream::from_iter(&["alpha", "beta", "gamma"]);
let s = stream::from_iter(vec![inner1, inner2]);
let merged: String = words
.flat_map(|s| stream::from_iter(s.chars()))
.collect().await;
assert_eq!(merged, "alphabetagamma");
let v :Vec<_> = s.flat_map(|s| s.into_stream()).collect().await;
assert_eq!(v, vec![1,2,3,4,5,6]);
let d3 = stream::from_iter(&[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
let d1: Vec<_> = d3
.flat_map(|item| stream::from_iter(item))
.flat_map(|item| stream::from_iter(item))
.collect().await;
assert_eq!(d1, [&1, &2, &3, &4, &5, &6, &7, &8]);
# });
```
"#]

Loading…
Cancel
Save