Struct OptionFuture

#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct OptionFuture<F> { /* private fields */ }

A future representing a value which may or may not be present.

Created by the From implementation for Option.

Examples

# futures::executor::block_on(async {
use futures::future::OptionFuture;

let mut a: OptionFuture<_> = Some(async { 123 }).into();
assert_eq!(a.await, Some(123));

a = None.into();
assert_eq!(a.await, None);
# });

Trait Implementations

impl<'__pin, F> Unpin for OptionFuture<F> where PinnedFieldsOf<__Origin<'__pin, F>>: Unpin,

impl<F> Default for OptionFuture<F>

fn default() -> Self

impl<F: Clone> Clone for OptionFuture<F>

fn clone(&self) -> OptionFuture<F>

impl<F: Debug> Debug for OptionFuture<F>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<F: FusedFuture> FusedFuture for OptionFuture<F>

fn is_terminated(&self) -> bool

impl<F: Future> Future for OptionFuture<F>

type Output = Option<<F as Future>::Output>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

impl<T> From<Option<T>> for OptionFuture<T>

fn from(option: Option<T>) -> Self

Auto Trait Implementations

impl<F> Freeze for OptionFuture<F> where Option<F>: Freeze,

impl<F> RefUnwindSafe for OptionFuture<F> where Option<F>: RefUnwindSafe,

impl<F> Send for OptionFuture<F> where Option<F>: Send,

impl<F> Sync for OptionFuture<F> where Option<F>: Sync,

impl<F> UnsafeUnpin for OptionFuture<F> where Option<F>: UnsafeUnpin,

impl<F> UnwindSafe for OptionFuture<F> where Option<F>: UnwindSafe,

Blanket Implementations

impl<F> IntoFuture for OptionFuture<F> where F: Future,

type Output = <F as Future>::Output;
type IntoFuture = F;
fn into_future(self) -> <F as IntoFuture>::IntoFuture

impl<T> Any for OptionFuture<F> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for OptionFuture<F> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for OptionFuture<F> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for OptionFuture<F> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for OptionFuture<F>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> FutureExt for OptionFuture<F> where T: Future + ?Sized,

impl<T> ToOwned for OptionFuture<F> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for OptionFuture<F> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for OptionFuture<F> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for OptionFuture<F> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>