abstract and encapsulate the awkward OptionFuture into Stream pattern
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -11,11 +11,14 @@ pub trait OptionExt<T> {
|
||||
impl<T, Fut> OptionExt<T> for OptionFuture<Fut>
|
||||
where
|
||||
Fut: Future<Output = T> + Send,
|
||||
T: Send,
|
||||
{
|
||||
#[inline]
|
||||
fn is_none_or(self, f: impl FnOnce(&T) -> bool + Send) -> impl Future<Output = bool> + 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<Output = bool> + Send {
|
||||
self.map(|o| o.as_ref().is_some_and(f))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user