From ccb59ce5e14be1c233eabf73e0c058c088c55951 Mon Sep 17 00:00:00 2001 From: EFanZh Date: Thu, 5 Aug 2021 18:39:28 +0800 Subject: [PATCH] Implement `Default` trait for `OptionFuture` (#2471) This provides an easy way to create empty `OptionFuture`s. --- futures-util/src/future/option.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/futures-util/src/future/option.rs b/futures-util/src/future/option.rs index 426fe50fea..0bc377758a 100644 --- a/futures-util/src/future/option.rs +++ b/futures-util/src/future/option.rs @@ -31,6 +31,12 @@ pin_project! { } } +impl Default for OptionFuture { + fn default() -> Self { + Self { inner: None } + } +} + impl Future for OptionFuture { type Output = Option;