Add broad_find_map() to stream utils.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-07-01 22:39:07 +00:00
parent a2b4c07cf7
commit ad9ddd91cd
2 changed files with 63 additions and 0 deletions

View File

@@ -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,