add ready_try_for_each to TryReadyExt extension utils
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
use futures::{
|
||||
future::{ready, Ready},
|
||||
stream::{AndThen, TryStream, TryStreamExt},
|
||||
stream::{AndThen, TryForEach, TryStream, TryStreamExt},
|
||||
};
|
||||
|
||||
use crate::Result;
|
||||
@@ -18,6 +18,12 @@ where
|
||||
fn ready_and_then<U, F>(self, f: F) -> AndThen<Self, Ready<Result<U, E>>, impl FnMut(S::Ok) -> Ready<Result<U, E>>>
|
||||
where
|
||||
F: Fn(S::Ok) -> Result<U, E>;
|
||||
|
||||
fn ready_try_for_each<F>(
|
||||
self, f: F,
|
||||
) -> TryForEach<Self, Ready<Result<(), E>>, impl FnMut(S::Ok) -> Ready<Result<(), E>>>
|
||||
where
|
||||
F: Fn(S::Ok) -> Result<(), E>;
|
||||
}
|
||||
|
||||
impl<T, E, S> TryReadyExt<T, E, S> for S
|
||||
@@ -32,4 +38,14 @@ where
|
||||
{
|
||||
self.and_then(move |t| ready(f(t)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn ready_try_for_each<F>(
|
||||
self, f: F,
|
||||
) -> TryForEach<Self, Ready<Result<(), E>>, impl FnMut(S::Ok) -> Ready<Result<(), E>>>
|
||||
where
|
||||
F: Fn(S::Ok) -> Result<(), E>,
|
||||
{
|
||||
self.try_for_each(move |t| ready(f(t)))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user