Skip to content

Commit f318786

Browse files
committed
fix: Stabilize stream method
1 parent 9a62df1 commit f318786

File tree

9 files changed

+63
-44
lines changed

9 files changed

+63
-44
lines changed

Diff for: Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ default = [
3535
"pin-project-lite",
3636
]
3737
docs = ["attributes", "unstable", "default"]
38-
unstable = ["std", "broadcaster", "futures-timer"]
38+
unstable = ["std", "broadcaster"]
3939
attributes = ["async-attributes"]
4040
std = [
4141
"alloc",

Diff for: src/prelude.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,14 @@ cfg_std! {
3838
pub use crate::io::prelude::SeekExt as _;
3939
#[doc(no_inline)]
4040
pub use crate::io::prelude::WriteExt as _;
41-
}
42-
43-
cfg_default! {
44-
#[doc(no_inline)]
45-
pub use crate::task_local;
46-
}
4741

48-
cfg_unstable! {
4942
#[doc(no_inline)]
5043
pub use crate::stream::DoubleEndedStream;
5144
#[doc(no_inline)]
5245
pub use crate::stream::ExactSizeStream;
5346
}
47+
48+
cfg_default! {
49+
#[doc(no_inline)]
50+
pub use crate::task_local;
51+
}

Diff for: src/stream/double_ended_stream/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::stream::Stream;
22

3-
use std::pin::Pin;
4-
use std::task::{Context, Poll};
3+
use core::pin::Pin;
4+
use core::task::{Context, Poll};
55

66
mod next_back;
77
mod nth_back;

Diff for: src/stream/mod.rs

+20-17
Original file line numberDiff line numberDiff line change
@@ -300,39 +300,42 @@
300300
//! [`take`]: trait.Stream.html#method.take
301301
//! [`min`]: trait.Stream.html#method.min
302302
303-
pub use double_ended_stream::DoubleEndedStream;
304303
pub use empty::{empty, Empty};
305-
pub use exact_size_stream::ExactSizeStream;
306304
pub use from_fn::{from_fn, FromFn};
307305
pub use from_iter::{from_iter, FromIter};
308-
pub use fused_stream::FusedStream;
309-
pub use interval::{interval, Interval};
310306
pub use once::{once, Once};
311-
pub use pending::{pending, Pending};
312-
pub use product::Product;
313307
pub use repeat::{repeat, Repeat};
314308
pub use repeat_with::{repeat_with, RepeatWith};
315-
pub use stream::Merge;
316309
pub use stream::*;
317-
pub use successors::{successors, Successors};
318-
pub use sum::Sum;
319310

320311
pub(crate) mod stream;
321312

322-
mod double_ended_stream;
323313
mod empty;
324-
mod exact_size_stream;
325314
mod from_fn;
326315
mod from_iter;
327-
mod fused_stream;
328-
mod interval;
329316
mod once;
330-
mod pending;
331-
mod product;
332317
mod repeat;
333318
mod repeat_with;
334-
mod successors;
335-
mod sum;
319+
320+
cfg_std! {
321+
pub use double_ended_stream::DoubleEndedStream;
322+
pub use exact_size_stream::ExactSizeStream;
323+
pub use fused_stream::FusedStream;
324+
pub use interval::{interval, Interval};
325+
pub use pending::{pending, Pending};
326+
pub use product::Product;
327+
pub use successors::{successors, Successors};
328+
pub use sum::Sum;
329+
330+
mod double_ended_stream;
331+
mod exact_size_stream;
332+
mod fused_stream;
333+
mod interval;
334+
mod pending;
335+
mod product;
336+
mod successors;
337+
mod sum;
338+
}
336339

337340
cfg_unstable! {
338341
mod from_stream;

Diff for: src/stream/once.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use pin_project_lite::pin_project;
55
use crate::stream::Stream;
66
use crate::task::{Context, Poll};
77

8+
#[cfg(feature = "std")]
89
use crate::stream::DoubleEndedStream;
910

1011
/// Creates a stream that yields a single item.
@@ -49,6 +50,7 @@ impl<T> Stream for Once<T> {
4950
}
5051
}
5152

53+
#[cfg(feature = "std")]
5254
impl<T> DoubleEndedStream for Once<T> {
5355
fn poll_next_back(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
5456
Poll::Ready(self.project().value.take())

Diff for: src/stream/product.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use alloc::boxed::Box;
12
use core::future::Future;
23
use core::pin::Pin;
34

Diff for: src/stream/stream/mod.rs

+30-16
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ mod chain;
2727
mod cloned;
2828
mod cmp;
2929
mod copied;
30-
mod count;
3130
mod cycle;
32-
mod delay;
3331
mod enumerate;
3432
mod eq;
3533
mod filter;
@@ -49,7 +47,6 @@ mod map;
4947
mod max;
5048
mod max_by;
5149
mod max_by_key;
52-
mod merge;
5350
mod min;
5451
mod min_by;
5552
mod min_by_key;
@@ -64,17 +61,13 @@ mod skip_while;
6461
mod step_by;
6562
mod take;
6663
mod take_while;
67-
mod throttle;
68-
mod timeout;
6964
mod try_fold;
7065
mod try_for_each;
71-
mod unzip;
7266
mod zip;
7367

7468
use all::AllFuture;
7569
use any::AnyFuture;
7670
use cmp::CmpFuture;
77-
use count::CountFuture;
7871
use cycle::Cycle;
7972
use enumerate::Enumerate;
8073
use eq::EqFuture;
@@ -101,33 +94,46 @@ use partial_cmp::PartialCmpFuture;
10194
use position::PositionFuture;
10295
use try_fold::TryFoldFuture;
10396
use try_for_each::TryForEachFuture;
104-
use unzip::UnzipFuture;
10597

10698
pub use chain::Chain;
10799
pub use cloned::Cloned;
108100
pub use copied::Copied;
109-
pub use delay::Delay;
110101
pub use filter::Filter;
111102
pub use fuse::Fuse;
112103
pub use inspect::Inspect;
113104
pub use map::Map;
114-
pub use merge::Merge;
115105
pub use scan::Scan;
116106
pub use skip::Skip;
117107
pub use skip_while::SkipWhile;
118108
pub use step_by::StepBy;
119109
pub use take::Take;
120110
pub use take_while::TakeWhile;
121-
pub use throttle::Throttle;
122-
pub use timeout::{Timeout, TimeoutError};
123111
pub use zip::Zip;
124112

125113
use core::cmp::Ordering;
126-
use core::future::Future;
127-
use core::pin::Pin;
128-
use core::time::Duration;
129114

130-
use crate::stream::{Product, Sum};
115+
cfg_std! {
116+
use core::time::Duration;
117+
use crate::stream::{Product, Sum};
118+
use alloc::boxed::Box;
119+
use core::future::Future;
120+
use core::pin::Pin;
121+
122+
use unzip::UnzipFuture;
123+
use count::CountFuture;
124+
125+
pub use throttle::Throttle;
126+
pub use merge::Merge;
127+
pub use delay::Delay;
128+
pub use timeout::{Timeout, TimeoutError};
129+
130+
mod timeout;
131+
mod throttle;
132+
mod merge;
133+
mod delay;
134+
mod unzip;
135+
mod count;
136+
}
131137

132138
cfg_unstable! {
133139
use crate::stream::FromStream;
@@ -357,6 +363,7 @@ extension_trait! {
357363
# }) }
358364
```
359365
"#]
366+
#[cfg(feature = "std")]
360367
fn throttle(self, d: Duration) -> Throttle<Self>
361368
where
362369
Self: Sized,
@@ -598,6 +605,7 @@ extension_trait! {
598605
# }) }
599606
```
600607
"#]
608+
#[cfg(feature = "std")]
601609
fn delay(self, dur: std::time::Duration) -> Delay<Self>
602610
where
603611
Self: Sized,
@@ -1652,6 +1660,7 @@ extension_trait! {
16521660
# Ok(()) }) }
16531661
```
16541662
"#]
1663+
#[cfg(feature = "std")]
16551664
fn timeout(self, dur: Duration) -> Timeout<Self>
16561665
where
16571666
Self: Stream + Sized,
@@ -1816,6 +1825,7 @@ extension_trait! {
18161825
# }) }
18171826
```
18181827
"#]
1828+
#[cfg(feature = "std")]
18191829
fn unzip<A, B, FromA, FromB>(self) -> impl Future<Output = (FromA, FromB)> [UnzipFuture<Self, FromA, FromB>]
18201830
where
18211831
FromA: Default + Extend<A>,
@@ -1913,6 +1923,7 @@ extension_trait! {
19131923
# });
19141924
```
19151925
"#]
1926+
#[cfg(feature = "std")]
19161927
fn merge<U>(self, other: U) -> Merge<Self, U>
19171928
where
19181929
Self: Sized,
@@ -2058,6 +2069,7 @@ extension_trait! {
20582069
# }) }
20592070
```
20602071
"#]
2072+
#[cfg(feature = "std")]
20612073
fn count(self) -> impl Future<Output = usize> [CountFuture<Self>]
20622074
where
20632075
Self: Sized,
@@ -2318,6 +2330,7 @@ extension_trait! {
23182330
# }) }
23192331
```
23202332
"#]
2333+
#[cfg(feature = "std")]
23212334
fn sum<'a, S>(
23222335
self,
23232336
) -> impl Future<Output = S> + 'a [Pin<Box<dyn Future<Output = S> + 'a>>]
@@ -2362,6 +2375,7 @@ extension_trait! {
23622375
# }) }
23632376
```
23642377
"#]
2378+
#[cfg(feature = "std")]
23652379
fn product<'a, P>(
23662380
self,
23672381
) -> impl Future<Output = P> + 'a [Pin<Box<dyn Future<Output = P> + 'a>>]

Diff for: src/stream/sum.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use alloc::boxed::Box;
12
use core::future::Future;
23
use core::pin::Pin;
34

Diff for: src/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn abort_on_panic<T>(f: impl FnOnce() -> T) -> T {
2121
}
2222

2323
/// Generates a random number in `0..n`.
24-
#[cfg(any(feature = "unstable", feature = "default"))]
24+
#[cfg(any(feature = "std", feature = "default"))]
2525
pub fn random(n: u32) -> u32 {
2626
use std::cell::Cell;
2727
use std::num::Wrapping;

0 commit comments

Comments
 (0)