Skip to content

Commit a1b1132

Browse files
committed
Remove Stream::next
This is a temporary change only, as we wait to resolve dynamic dispatch issues. The `Stream::next` method and corresponding documentation are expected to be fully restored once we have a path to proceed. Ref: rust-lang/rfcs#2996 (comment) update docs
1 parent 0c8db16 commit a1b1132

File tree

3 files changed

+9
-85
lines changed

3 files changed

+9
-85
lines changed

library/core/src/stream/mod.rs

+9-36
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
//! exist and what you can do with them. The methods of these traits are worth
1717
//! putting some extra study time into.
1818
//! * Functions provide some helpful ways to create some basic streams.
19-
//! * [Structs] are often the return types of the various methods on this
19+
//! * Structs are often the return types of the various methods on this
2020
//! module's traits. You'll usually want to look at the method that creates
2121
//! the `struct`, rather than the `struct` itself. For more detail about why,
2222
//! see '[Implementing Stream](#implementing-stream)'.
2323
//!
2424
//! [Traits]: #traits
25-
//! [Structs]: #structs
2625
//!
2726
//! That's it! Let's dig into streams.
2827
//!
@@ -41,17 +40,17 @@
4140
//! ```
4241
//!
4342
//! Unlike `Iterator`, `Stream` makes a distinction between the [`poll_next`]
44-
//! method which is used when implementing a `Stream`, and the [`next`] method
45-
//! which is used when consuming a stream. Consumers of `Stream` only need to
46-
//! consider [`next`], which when called, returns a future which yields
47-
//! yields [`Option`][`<Item>`].
43+
//! method which is used when implementing a `Stream`, and a (to-be-implemented)
44+
//! `next` method which is used when consuming a stream. Consumers of `Stream`
45+
//! only need to consider `next`, which when called, returns a future which
46+
//! yields `Option<Stream::Item>`.
4847
//!
49-
//! The future returned by [`next`] will yield `Some(Item)` as long as there are
48+
//! The future returned by `next` will yield `Some(Item)` as long as there are
5049
//! elements, and once they've all been exhausted, will yield `None` to indicate
5150
//! that iteration is finished. If we're waiting on something asynchronous to
5251
//! resolve, the future will wait until the stream is ready to yield again.
5352
//!
54-
//! Individual streams may choose to resume iteration, and so calling [`next`]
53+
//! Individual streams may choose to resume iteration, and so calling `next`
5554
//! again may or may not eventually yield `Some(Item)` again at some point.
5655
//!
5756
//! [`Stream`]'s full definition includes a number of other methods as well,
@@ -60,8 +59,6 @@
6059
//!
6160
//! [`Poll`]: super::task::Poll
6261
//! [`poll_next`]: Stream::poll_next
63-
//! [`next`]: Stream::next
64-
//! [`<Item>`]: Stream::Item
6562
//!
6663
//! # Implementing Stream
6764
//!
@@ -112,36 +109,12 @@
112109
//! }
113110
//! }
114111
//! }
115-
//!
116-
//! // And now we can use it!
117-
//! # async fn run() {
118-
//! #
119-
//! let mut counter = Counter::new();
120-
//!
121-
//! let x = counter.next().await.unwrap();
122-
//! println!("{}", x);
123-
//!
124-
//! let x = counter.next().await.unwrap();
125-
//! println!("{}", x);
126-
//!
127-
//! let x = counter.next().await.unwrap();
128-
//! println!("{}", x);
129-
//!
130-
//! let x = counter.next().await.unwrap();
131-
//! println!("{}", x);
132-
//!
133-
//! let x = counter.next().await.unwrap();
134-
//! println!("{}", x);
135-
//! #
136-
//! }
137112
//! ```
138113
//!
139-
//! This will print `1` through `5`, each on their own line.
140-
//!
141114
//! # Laziness
142115
//!
143116
//! Streams are *lazy*. This means that just creating a stream doesn't _do_ a
144-
//! whole lot. Nothing really happens until you call [`next`]. This is sometimes a
117+
//! whole lot. Nothing really happens until you call `next`. This is sometimes a
145118
//! source of confusion when creating a stream solely for its side effects. The
146119
//! compiler will warn us about this kind of behavior:
147120
//!
@@ -151,4 +124,4 @@
151124
152125
mod stream;
153126

154-
pub use stream::{Next, Stream};
127+
pub use stream::Stream;

library/core/src/stream/stream/mod.rs

-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
mod next;
2-
3-
pub use next::Next;
4-
51
use crate::ops::DerefMut;
62
use crate::pin::Pin;
73
use crate::task::{Context, Poll};
@@ -81,21 +77,6 @@ pub trait Stream {
8177
fn size_hint(&self) -> (usize, Option<usize>) {
8278
(0, None)
8379
}
84-
85-
/// Advances the stream and returns a future which yields the next value.
86-
///
87-
/// The returned future yields [`None`] when iteration is finished.
88-
/// Individual stream implementations may choose to resume iteration, and so
89-
/// calling `next()` again may or may not eventually start yielding
90-
/// [`Some(Item)`] again at some point.
91-
///
92-
/// [`Some(Item)`]: Some
93-
fn next(&mut self) -> Next<'_, Self>
94-
where
95-
Self: Unpin,
96-
{
97-
Next::new(self)
98-
}
9980
}
10081

10182
#[unstable(feature = "async_stream", issue = "79024")]

library/core/src/stream/stream/next.rs

-30
This file was deleted.

0 commit comments

Comments
 (0)