diff --git a/src/core/utils/stream/try_ready.rs b/src/core/utils/stream/try_ready.rs index 0daed26e..b0a2b6c5 100644 --- a/src/core/utils/stream/try_ready.rs +++ b/src/core/utils/stream/try_ready.rs @@ -3,7 +3,7 @@ use futures::{ future::{ready, Ready}, - stream::{AndThen, TryFold, TryForEach, TryStream, TryStreamExt}, + stream::{AndThen, TryFilterMap, TryFold, TryForEach, TryStream, TryStreamExt}, }; use crate::Result; @@ -20,11 +20,11 @@ where where F: Fn(S::Ok) -> Result; - fn ready_try_for_each( + fn ready_try_filter_map( self, f: F, - ) -> TryForEach>, impl FnMut(S::Ok) -> Ready>> + ) -> TryFilterMap, E>>, impl FnMut(S::Ok) -> Ready, E>>> where - F: FnMut(S::Ok) -> Result<(), E>; + F: Fn(S::Ok) -> Result, E>; fn ready_try_fold( self, init: U, f: F, @@ -38,6 +38,12 @@ where where F: Fn(U, S::Ok) -> Result, U: Default; + + fn ready_try_for_each( + self, f: F, + ) -> TryForEach>, impl FnMut(S::Ok) -> Ready>> + where + F: FnMut(S::Ok) -> Result<(), E>; } impl TryReadyExt for S @@ -53,14 +59,13 @@ where self.and_then(move |t| ready(f(t))) } - #[inline] - fn ready_try_for_each( - self, mut f: F, - ) -> TryForEach>, impl FnMut(S::Ok) -> Ready>> + fn ready_try_filter_map( + self, f: F, + ) -> TryFilterMap, E>>, impl FnMut(S::Ok) -> Ready, E>>> where - F: FnMut(S::Ok) -> Result<(), E>, + F: Fn(S::Ok) -> Result, E>, { - self.try_for_each(move |t| ready(f(t))) + self.try_filter_map(move |t| ready(f(t))) } #[inline] @@ -83,4 +88,14 @@ where { self.ready_try_fold(U::default(), f) } + + #[inline] + fn ready_try_for_each( + self, mut f: F, + ) -> TryForEach>, impl FnMut(S::Ok) -> Ready>> + where + F: FnMut(S::Ok) -> Result<(), E>, + { + self.try_for_each(move |t| ready(f(t))) + } }