futures_core/future/
either.rs1use {task, Future, Poll, Stream};
2
3use either::Either;
4
5impl<A, B> Future for Either<A, B>
6 where A: Future,
7 B: Future<Item = A::Item, Error = A::Error>
8{
9 type Item = A::Item;
10 type Error = A::Error;
11
12 fn poll(&mut self, cx: &mut task::Context) -> Poll<A::Item, A::Error> {
13 match *self {
14 Either::Left(ref mut a) => a.poll(cx),
15 Either::Right(ref mut b) => b.poll(cx),
16 }
17 }
18}
19
20impl<A, B> Stream for Either<A, B>
21 where A: Stream,
22 B: Stream<Item = A::Item, Error = A::Error>
23{
24 type Item = A::Item;
25 type Error = A::Error;
26
27 fn poll_next(&mut self, cx: &mut task::Context) -> Poll<Option<A::Item>, A::Error> {
28 match *self {
29 Either::Left(ref mut a) => a.poll_next(cx),
30 Either::Right(ref mut b) => b.poll_next(cx),
31 }
32 }
33}