ps_promise/implementations/future.rs
1use std::{
2 future::Future,
3 task::Poll::{Pending, Ready},
4};
5
6use crate::{Promise, PromiseRejection};
7
8impl<T, E> Future for Promise<T, E>
9where
10 T: Unpin,
11 E: PromiseRejection,
12{
13 type Output = Result<T, E>;
14
15 fn poll(
16 self: std::pin::Pin<&mut Self>,
17 cx: &mut std::task::Context<'_>,
18 ) -> std::task::Poll<Self::Output> {
19 let this = self.get_mut();
20
21 this.poll(cx);
22
23 this.consume().map_or_else(|| Pending, Ready)
24 }
25}