Skip to content

Commit 2ea3529

Browse files
committed
stream: use current_thread flavor instead of futures::executor::block_on
1 parent e0762b6 commit 2ea3529

File tree

8 files changed

+75
-106
lines changed

8 files changed

+75
-106
lines changed

tokio-stream/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ tokio = { version = "1.2.0", path = "../tokio", features = ["full", "test-util"]
4646
async-stream = "0.3"
4747
parking_lot = "0.12.0"
4848
tokio-test = { version = "0.4", path = "../tokio-test" }
49-
futures = { version = "0.3", default-features = false, features = ["executor"] }
49+
futures = { version = "0.3", default-features = false }
5050

5151
[package.metadata.docs.rs]
5252
all-features = true

tokio-stream/src/empty.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,17 @@ unsafe impl<T> Sync for Empty<T> {}
2424
/// Basic usage:
2525
///
2626
/// ```
27-
/// # use futures::executor::block_on;
2827
/// use tokio_stream::{self as stream, StreamExt};
2928
///
3029
/// # /*
3130
/// #[tokio::main]
32-
/// async fn main() {
3331
/// # */
34-
/// # block_on(async {
32+
/// # #[tokio::main(flavor = "current_thread")]
33+
/// async fn main() {
3534
/// let mut none = stream::empty::<i32>();
3635
///
3736
/// assert_eq!(None, none.next().await);
38-
/// # })
39-
/// # /*
4037
/// }
41-
/// # */
4238
/// ```
4339
pub const fn empty<T>() -> Empty<T> {
4440
Empty(PhantomData)

tokio-stream/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,19 @@
3232
//! `while let` loop as follows:
3333
//!
3434
//! ```rust
35-
//! # use futures::executor::block_on;
3635
//! use tokio_stream::{self as stream, StreamExt};
3736
//!
3837
//! # /*
3938
//! #[tokio::main]
40-
//! async fn main() {
4139
//! # */
42-
//! # block_on(async {
40+
//! # #[tokio::main(flavor = "current_thread")]
41+
//! async fn main() {
4342
//! let mut stream = stream::iter(vec![0, 1, 2]);
4443
//!
4544
//! while let Some(value) = stream.next().await {
4645
//! println!("Got {}", value);
4746
//! }
48-
//! # })
49-
//! # /*
5047
//! }
51-
//! # */
5248
//! ```
5349
//!
5450
//! # Returning a Stream from a function

tokio-stream/src/once.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,21 @@ impl<I> Unpin for Once<I> {}
2020
/// # Examples
2121
///
2222
/// ```
23-
/// # use futures::executor::block_on;
2423
/// use tokio_stream::{self as stream, StreamExt};
2524
///
2625
/// # /*
2726
/// #[tokio::main]
28-
/// async fn main() {
2927
/// # */
30-
/// # block_on(async {
28+
/// # #[tokio::main(flavor = "current_thread")]
29+
/// async fn main() {
3130
/// // one is the loneliest number
3231
/// let mut one = stream::once(1);
3332
///
3433
/// assert_eq!(Some(1), one.next().await);
3534
///
3635
/// // just one, that's all we get
3736
/// assert_eq!(None, one.next().await);
38-
/// # })
39-
/// # /*
4037
/// }
41-
/// # */
4238
/// ```
4339
pub fn once<T>(value: T) -> Once<T> {
4440
Once {

tokio-stream/src/stream_close.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ pin_project! {
1515
/// Using `StreamNotifyClose` to handle closed streams with `StreamMap`.
1616
///
1717
/// ```
18-
/// # use futures::executor::block_on;
1918
/// use tokio_stream::{StreamExt, StreamMap, StreamNotifyClose};
2019
///
2120
/// # /*
2221
/// #[tokio::main]
23-
/// async fn main() {
2422
/// # */
25-
/// # block_on(async {
23+
/// # #[tokio::main(flavor = "current_thread")]
24+
/// async fn main() {
2625
/// let mut map = StreamMap::new();
2726
/// let stream = StreamNotifyClose::new(tokio_stream::iter(vec![0, 1]));
2827
/// let stream2 = StreamNotifyClose::new(tokio_stream::iter(vec![0, 1]));
@@ -34,10 +33,7 @@ pin_project! {
3433
/// None => println!("stream {key:?} closed"),
3534
/// }
3635
/// }
37-
/// # })
38-
/// # /*
3936
/// }
40-
/// # */
4137
/// ```
4238
#[must_use = "streams do nothing unless polled"]
4339
pub struct StreamNotifyClose<S> {

0 commit comments

Comments
 (0)