#![allow(clippy::wrong_self_convention)] use futures::{Future, FutureExt, future::OptionFuture}; pub trait OptionExt { fn is_none_or(self, f: impl FnOnce(&T) -> bool + Send) -> impl Future + Send; fn is_some_and(self, f: impl FnOnce(&T) -> bool + Send) -> impl Future + Send; } impl OptionExt for OptionFuture where Fut: Future + Send, T: Send, { #[inline] fn is_none_or(self, f: impl FnOnce(&T) -> bool + Send) -> impl Future + Send { self.map(|o| o.as_ref().is_none_or(f)) } #[inline] fn is_some_and(self, f: impl FnOnce(&T) -> bool + Send) -> impl Future + Send { self.map(|o| o.as_ref().is_some_and(f)) } }