-
-
Save peterbudai/a0bc6617c138b84c7647008e3f311d1e to your computer and use it in GitHub Desktop.
Stream combinator for different underlying stream types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Either is not implemented for Streams in futures 0.1.x, so we use our own. | |
enum EitherStream<A, B> { | |
A(A), | |
B(B), | |
} | |
impl<A, B> Stream for EitherStream<A, B> | |
where | |
A: Stream, | |
B: Stream<Item = A::Item, Error = A::Error>, | |
{ | |
type Item = A::Item; | |
type Error = A::Error; | |
fn poll(&mut self) -> Poll<Option<A::Item>, A::Error> { | |
match *self { | |
EitherStream::A(ref mut a) => a.poll(), | |
EitherStream::B(ref mut b) => b.poll(), | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment