diff --git a/src/core/utils/future/try_ext_ext.rs b/src/core/utils/future/try_ext_ext.rs index d30d2cac..7c0b36a2 100644 --- a/src/core/utils/future/try_ext_ext.rs +++ b/src/core/utils/future/try_ext_ext.rs @@ -10,6 +10,17 @@ pub trait TryExtExt where Self: TryFuture + Send, { + /// Resolves to a bool for whether the TryFuture (Future of a Result) + /// resolved to Ok or Err. + /// + /// is_ok() has to consume *self rather than borrow. The intent of this + /// extension is therefor for a caller only ever caring about result status + /// while discarding all contents. + #[allow(clippy::wrong_self_convention)] + fn is_ok(self) -> MapOkOrElse bool, impl FnOnce(Self::Error) -> bool> + where + Self: Sized; + fn map_ok_or( self, default: U, f: F, ) -> MapOkOrElse U, impl FnOnce(Self::Error) -> U> @@ -32,6 +43,14 @@ impl TryExtExt for Fut where Fut: TryFuture + Send, { + #[inline] + fn is_ok(self) -> MapOkOrElse bool, impl FnOnce(Self::Error) -> bool> + where + Self: Sized, + { + self.map_ok_or(false, |_| true) + } + #[inline] fn map_ok_or( self, default: U, f: F,