Add broad_find_map() to stream utils.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -32,6 +32,13 @@ where
|
||||
F: Fn(&Item) -> bool + Send + 'a,
|
||||
Item: Send;
|
||||
|
||||
fn ready_find_map<'a, F, U>(self, f: F) -> impl Future<Output = Option<U>> + Send
|
||||
where
|
||||
Self: Send + Unpin + 'a,
|
||||
F: Fn(Item) -> Option<U> + Send + 'a,
|
||||
Item: Send,
|
||||
U: Send;
|
||||
|
||||
fn ready_filter<'a, F>(
|
||||
self,
|
||||
f: F,
|
||||
@@ -130,6 +137,20 @@ where
|
||||
.map(|(curr, _next)| curr)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn ready_find_map<'a, F, U>(self, f: F) -> impl Future<Output = Option<U>> + Send
|
||||
where
|
||||
Self: Send + Unpin + 'a,
|
||||
F: Fn(Item) -> Option<U> + Send + 'a,
|
||||
Item: Send,
|
||||
U: Send,
|
||||
{
|
||||
self.ready_filter_map(f)
|
||||
.take(1)
|
||||
.into_future()
|
||||
.map(|(curr, _next)| curr)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn ready_filter<'a, F>(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user