Skip to main content

ps_promise/methods/
wrap.rs

1use std::future::Future;
2
3use crate::{Promise, WrappedPromiseRejection};
4
5impl<T, E> Promise<T, WrappedPromiseRejection<E>>
6where
7    T: Unpin,
8    E: Send + Unpin + 'static,
9{
10    pub fn wrap(future: impl Future<Output = Result<T, E>> + Send + 'static) -> Self {
11        Self::new(async move { Ok(future.await?) })
12    }
13}