add broad_flat_map

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2025-01-26 09:59:59 +00:00
parent 98f9570547
commit 2b730a30ad

View file

@ -35,6 +35,13 @@ where
Fut: Future<Output = Option<U>> + Send,
U: Send;
fn broadn_flat_map<F, Fut, U, N>(self, n: N, f: F) -> impl Stream<Item = U> + Send
where
N: Into<Option<usize>>,
F: Fn(Item) -> Fut + Send,
Fut: Stream<Item = U> + Send + Unpin,
U: Send;
fn broadn_then<F, Fut, U, N>(self, n: N, f: F) -> impl Stream<Item = U> + Send
where
N: Into<Option<usize>>,
@ -70,6 +77,16 @@ where
self.broadn_filter_map(None, f)
}
#[inline]
fn broad_flat_map<F, Fut, U>(self, f: F) -> impl Stream<Item = U> + Send
where
F: Fn(Item) -> Fut + Send,
Fut: Stream<Item = U> + Send + Unpin,
U: Send,
{
self.broadn_flat_map(None, f)
}
#[inline]
fn broad_then<F, Fut, U>(self, f: F) -> impl Stream<Item = U> + Send
where
@ -122,6 +139,17 @@ where
.ready_filter_map(identity)
}
#[inline]
fn broadn_flat_map<F, Fut, U, N>(self, n: N, f: F) -> impl Stream<Item = U> + Send
where
N: Into<Option<usize>>,
F: Fn(Item) -> Fut + Send,
Fut: Stream<Item = U> + Send + Unpin,
U: Send,
{
self.flat_map_unordered(n.into().unwrap_or_else(automatic_width), f)
}
#[inline]
fn broadn_then<F, Fut, U, N>(self, n: N, f: F) -> impl Stream<Item = U> + Send
where