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
33
34
35
36
37
38
39
40
use std::pin::Pin;
use std::task::{Context, Poll};
use futures_util::future::Either;
use crate::actor::Actor;
use crate::fut::ActorFuture;
impl<A, B, Act> ActorFuture<Act> for Either<A, B>
where
A: ActorFuture<Act>,
B: ActorFuture<Act, Output = A::Output>,
Act: Actor,
{
type Output = A::Output;
fn poll(
self: Pin<&mut Self>,
act: &mut Act,
ctx: &mut Act::Context,
task: &mut Context<'_>,
) -> Poll<A::Output> {
let this = unsafe {
match self.get_unchecked_mut() {
Either::Left(a) => Either::Left(Pin::new_unchecked(a)),
Either::Right(b) => Either::Right(Pin::new_unchecked(b)),
}
};
match this {
Either::Left(left) => left.poll(act, ctx, task),
Either::Right(right) => right.poll(act, ctx, task),
}
}
}