1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use super::{Context, Effectful, Poll};
use std::pin::Pin;
use pin_project::{pin_project, project};
#[pin_project]
pub enum Either<L, R> {
A(#[pin] L),
B(#[pin] R),
}
impl<Output, Effect, L, R> Effectful for Either<L, R>
where
L: Effectful<Output = Output, Effect = Effect>,
R: Effectful<Output = Output, Effect = Effect>,
{
type Output = Output;
type Effect = Effect;
#[inline]
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect> {
#[project]
match self.project() {
Either::A(left) => left.poll(cx),
Either::B(right) => right.poll(cx),
}
}
}