makepad_futures/future/
ready.rs

1use std::{
2    future::Future,
3    pin::Pin,
4    task::{Context, Poll},
5};
6
7#[derive(Clone, Debug)]
8pub struct Ready<T> {
9    value: Option<T>,
10}
11
12impl<T> Future for Ready<T> {
13    type Output = T;
14
15    fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
16        Poll::Ready(self.value.take().expect("polling after completion"))
17    }
18}
19
20impl<T> Unpin for Ready<T> {}
21
22pub fn ready<T>(value: T) -> Ready<T> {
23    Ready { value: Some(value) }
24}