summaryrefslogtreecommitdiffstats
path: root/futures/src/stream.rs
diff options
context:
space:
mode:
authorLibravatar Héctor <hector@hecrj.dev>2025-02-21 19:21:10 +0100
committerLibravatar GitHub <noreply@github.com>2025-02-21 19:21:10 +0100
commitf1ed99cb47997e1d194a41e7cdf2846f8eb5f8fa (patch)
treeb2eeb7537ffd49bfbdd24c1a9580870eca99caa6 /futures/src/stream.rs
parent81ca3d2a223d62fbb48b93dcea5409f6212605fa (diff)
parent800a73ddd7d4a2e0b1ed23ec565cbc6325b3b7f0 (diff)
downloadiced-f1ed99cb47997e1d194a41e7cdf2846f8eb5f8fa.tar.gz
iced-f1ed99cb47997e1d194a41e7cdf2846f8eb5f8fa.tar.bz2
iced-f1ed99cb47997e1d194a41e7cdf2846f8eb5f8fa.zip
Merge pull request #2809 from iced-rs/rust-2024
Update to Rust 2024
Diffstat (limited to 'futures/src/stream.rs')
-rw-r--r--futures/src/stream.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/futures/src/stream.rs b/futures/src/stream.rs
index af2f8c99..ee9c0c14 100644
--- a/futures/src/stream.rs
+++ b/futures/src/stream.rs
@@ -2,21 +2,16 @@
use futures::channel::mpsc;
use futures::stream::{self, Stream, StreamExt};
-use std::future::Future;
-
/// Creates a new [`Stream`] that produces the items sent from a [`Future`]
/// to the [`mpsc::Sender`] provided to the closure.
///
/// This is a more ergonomic [`stream::unfold`], which allows you to go
/// from the "world of futures" to the "world of streams" by simply looping
/// and publishing to an async channel from inside a [`Future`].
-pub fn channel<T, F>(
+pub fn channel<T>(
size: usize,
- f: impl FnOnce(mpsc::Sender<T>) -> F,
-) -> impl Stream<Item = T>
-where
- F: Future<Output = ()>,
-{
+ f: impl AsyncFnOnce(mpsc::Sender<T>),
+) -> impl Stream<Item = T> {
let (sender, receiver) = mpsc::channel(size);
let runner = stream::once(f(sender)).filter_map(|_| async { None });
@@ -26,13 +21,10 @@ where
/// Creates a new [`Stream`] that produces the items sent from a [`Future`]
/// that can fail to the [`mpsc::Sender`] provided to the closure.
-pub fn try_channel<T, E, F>(
+pub fn try_channel<T, E>(
size: usize,
- f: impl FnOnce(mpsc::Sender<T>) -> F,
-) -> impl Stream<Item = Result<T, E>>
-where
- F: Future<Output = Result<(), E>>,
-{
+ f: impl AsyncFnOnce(mpsc::Sender<T>) -> Result<(), E>,
+) -> impl Stream<Item = Result<T, E>> {
let (sender, receiver) = mpsc::channel(size);
let runner = stream::once(f(sender)).filter_map(|result| async {