2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-04-08 17:36:43 +00:00

feat: Add Stream trait for Flatten

This commit is contained in:
k-nasa 2019-10-18 12:20:02 +09:00
parent cd862083a5
commit 8138afbfad

View file

@ -54,6 +54,19 @@ impl<S: Stream<Item: IntoStream>> Flatten<S> {
}
}
impl<S, U> Stream for Flatten<S>
where
S: Stream<Item: IntoStream<IntoStream = U, Item = U::Item>> + std::marker::Unpin,
U: Stream + std::marker::Unpin,
{
type Item = U::Item;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
self.as_mut().inner().poll_next(cx)
}
}
/// Real logic of both `Flatten` and `FlatMap` which simply delegate to
/// this type.
#[derive(Clone, Debug)]