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
41
42
43
44
use std::marker::PhantomData;
use std::pin::Pin;
use std::task;
use std::task::Poll;
use crate::actor::Actor;
use crate::fut::ActorFuture;
#[derive(Debug)]
#[must_use = "futures do nothing unless polled"]
pub struct Ready<T, A> {
inner: Option<T>,
act: PhantomData<A>,
}
impl<T, A> Unpin for Ready<T, A> {}
pub fn ready<T, A>(r: T) -> Ready<T, A> {
Ready {
inner: Some(r),
act: PhantomData,
}
}
impl<T, A> ActorFuture for Ready<T, A>
where
A: Actor,
{
type Output = T;
type Actor = A;
#[inline]
fn poll(
mut self: Pin<&mut Self>,
_: &mut Self::Actor,
_: &mut <Self::Actor as Actor>::Context,
_: &mut task::Context<'_>,
) -> Poll<Self::Output> {
Poll::Ready(self.inner.take().expect("cannot poll Result twice"))
}
}