pub struct OptionFut<F> { /* private fields */ }Expand description
Wrapper over Option that implements Future
If there is Some(T) then it is polled.
Otherwise it returns None immediately.
§Usage:
use cute_async::IntoFuture;
use core::task;
use core::pin::Pin;
use core::future::Future;
pub struct MyFuture;
impl Future for MyFuture {
type Output = ();
fn poll(self: Pin<&mut Self>, ctx: &mut task::Context<'_>) -> task::Poll<Self::Output> {
task::Poll::Ready(())
}
}
let fut_maybe = if true {
Some(MyFuture)
} else {
None
};
let mut future = fut_maybe.into_future();Trait Implementations§
impl<F: Unpin> Unpin for OptionFut<F>
Auto Trait Implementations§
impl<F> Freeze for OptionFut<F>where
F: Freeze,
impl<F> RefUnwindSafe for OptionFut<F>where
F: RefUnwindSafe,
impl<F> Send for OptionFut<F>where
F: Send,
impl<F> Sync for OptionFut<F>where
F: Sync,
impl<F> UnwindSafe for OptionFut<F>where
F: 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
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more