summaryrefslogtreecommitdiffstats
path: root/futures/src
diff options
context:
space:
mode:
Diffstat (limited to 'futures/src')
-rw-r--r--futures/src/backend/native/async_std.rs1
-rw-r--r--futures/src/backend/native/smol.rs1
-rw-r--r--futures/src/backend/native/thread_pool.rs1
-rw-r--r--futures/src/backend/native/tokio.rs4
-rw-r--r--futures/src/backend/null.rs1
-rw-r--r--futures/src/event.rs2
-rw-r--r--futures/src/executor.rs2
-rw-r--r--futures/src/keyboard.rs2
-rw-r--r--futures/src/runtime.rs2
-rw-r--r--futures/src/stream.rs20
-rw-r--r--futures/src/subscription.rs2
11 files changed, 11 insertions, 27 deletions
diff --git a/futures/src/backend/native/async_std.rs b/futures/src/backend/native/async_std.rs
index 86714f45..be258b26 100644
--- a/futures/src/backend/native/async_std.rs
+++ b/futures/src/backend/native/async_std.rs
@@ -1,5 +1,4 @@
//! An `async-std` backend.
-use futures::Future;
/// An `async-std` executor.
#[derive(Debug)]
diff --git a/futures/src/backend/native/smol.rs b/futures/src/backend/native/smol.rs
index 8d448e7f..9ac6a27d 100644
--- a/futures/src/backend/native/smol.rs
+++ b/futures/src/backend/native/smol.rs
@@ -1,5 +1,4 @@
//! A `smol` backend.
-use futures::Future;
/// A `smol` executor.
#[derive(Debug)]
diff --git a/futures/src/backend/native/thread_pool.rs b/futures/src/backend/native/thread_pool.rs
index c96f2682..a90cc53a 100644
--- a/futures/src/backend/native/thread_pool.rs
+++ b/futures/src/backend/native/thread_pool.rs
@@ -1,5 +1,4 @@
//! A `ThreadPool` backend.
-use futures::Future;
/// A thread pool executor for futures.
pub type Executor = futures::executor::ThreadPool;
diff --git a/futures/src/backend/native/tokio.rs b/futures/src/backend/native/tokio.rs
index c38ef566..911d788c 100644
--- a/futures/src/backend/native/tokio.rs
+++ b/futures/src/backend/native/tokio.rs
@@ -1,5 +1,4 @@
//! A `tokio` backend.
-use futures::Future;
/// A `tokio` executor.
pub type Executor = tokio::runtime::Runtime;
@@ -22,12 +21,11 @@ impl crate::Executor for Executor {
pub mod time {
//! Listen and react to time.
+ use crate::MaybeSend;
use crate::core::time::{Duration, Instant};
use crate::subscription::Subscription;
- use crate::MaybeSend;
use futures::stream;
- use std::future::Future;
/// Returns a [`Subscription`] that produces messages at a set interval.
///
diff --git a/futures/src/backend/null.rs b/futures/src/backend/null.rs
index 609b8b3f..f31415b9 100644
--- a/futures/src/backend/null.rs
+++ b/futures/src/backend/null.rs
@@ -1,5 +1,4 @@
//! A backend that does nothing!
-use futures::Future;
/// An executor that drops all the futures, instead of spawning them.
#[derive(Debug)]
diff --git a/futures/src/event.rs b/futures/src/event.rs
index 72ea78ad..bd75d82c 100644
--- a/futures/src/event.rs
+++ b/futures/src/event.rs
@@ -1,8 +1,8 @@
//! Listen to runtime events.
+use crate::MaybeSend;
use crate::core::event::{self, Event};
use crate::core::window;
use crate::subscription::{self, Subscription};
-use crate::MaybeSend;
/// Returns a [`Subscription`] to all the ignored runtime events.
///
diff --git a/futures/src/executor.rs b/futures/src/executor.rs
index 3b0d4af1..9c14a2c9 100644
--- a/futures/src/executor.rs
+++ b/futures/src/executor.rs
@@ -1,8 +1,6 @@
//! Choose your preferred executor to power a runtime.
use crate::MaybeSend;
-use futures::Future;
-
/// A type that can run futures.
pub trait Executor: Sized {
/// Creates a new [`Executor`].
diff --git a/futures/src/keyboard.rs b/futures/src/keyboard.rs
index 35f6b6fa..036edb9c 100644
--- a/futures/src/keyboard.rs
+++ b/futures/src/keyboard.rs
@@ -1,9 +1,9 @@
//! Listen to keyboard events.
+use crate::MaybeSend;
use crate::core;
use crate::core::event;
use crate::core::keyboard::{Event, Key, Modifiers};
use crate::subscription::{self, Subscription};
-use crate::MaybeSend;
/// Listens to keyboard key presses and calls the given function
/// to map them into actual messages.
diff --git a/futures/src/runtime.rs b/futures/src/runtime.rs
index 157e2c67..0f30b469 100644
--- a/futures/src/runtime.rs
+++ b/futures/src/runtime.rs
@@ -2,7 +2,7 @@
use crate::subscription;
use crate::{BoxFuture, BoxStream, Executor, MaybeSend};
-use futures::{channel::mpsc, Sink};
+use futures::{Sink, channel::mpsc};
use std::marker::PhantomData;
/// A batteries-included runtime of commands and subscriptions.
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 {
diff --git a/futures/src/subscription.rs b/futures/src/subscription.rs
index 3577d19f..f799d5f8 100644
--- a/futures/src/subscription.rs
+++ b/futures/src/subscription.rs
@@ -161,7 +161,7 @@ impl<T> Subscription<T> {
/// }
///
/// fn some_worker() -> impl Stream<Item = Event> {
- /// stream::channel(100, |mut output| async move {
+ /// stream::channel(100, async |mut output| {
/// // Create channel
/// let (sender, mut receiver) = mpsc::channel(100);
///