pub struct Promise<T: Send + 'static> { /* private fields */ }
Expand description
A representation of a “suspended” coroutine.
Implementations§
Source§impl<T: Send + 'static> Promise<T>
impl<T: Send + 'static> Promise<T>
Sourcepub fn await<F: FnOnce(Promise<T>) + Send + 'static>(f: F) -> T
pub fn await<F: FnOnce(Promise<T>) + Send + 'static>(f: F) -> T
Suspends the execution of the current coroutine,
calls the provided function with a Promise
representing
the current coroutine, and waits until the Promise
gets
resolved.
If the Promise
is dropped before resolving, Drop
will panic and the coroutine will leak.
If called outside of a coroutine, the current thread will be suspended instead.
Trait Implementations§
impl<T: Send + 'static> Send for Promise<T>
Auto Trait Implementations§
impl<T> Freeze for Promise<T>where
T: Freeze,
impl<T> RefUnwindSafe for Promise<T>where
T: RefUnwindSafe,
impl<T> !Sync for Promise<T>
impl<T> Unpin for Promise<T>where
T: Unpin,
impl<T> UnwindSafe for Promise<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more