Skip to content

Commit 0a526be

Browse files
committed
Remove futures_[un]ordered functions
1 parent 64eb779 commit 0a526be

File tree

4 files changed

+12
-51
lines changed

4 files changed

+12
-51
lines changed

futures-util/src/stream/futures_ordered.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ impl<T> Future for OrderWrapper<T>
8585
/// some of the later futures have already completed.
8686
///
8787
/// Note that you can create a ready-made `FuturesOrdered` via the
88-
/// `futures_ordered` function in the `stream` module, or you can start with an
89-
/// empty queue with the `FuturesOrdered::new` constructor.
88+
/// [`collect`](Iterator::collect) method, or you can start with an empty queue
89+
/// with the `FuturesOrdered::new` constructor.
9090
#[must_use = "streams do nothing unless polled"]
9191
pub struct FuturesOrdered<T: Future> {
9292
in_progress_queue: FuturesUnordered<OrderWrapper<T>>,
@@ -97,25 +97,6 @@ pub struct FuturesOrdered<T: Future> {
9797

9898
impl<T: Future> Unpin for FuturesOrdered<T> {}
9999

100-
/// Converts a list of futures into a `Stream` of results from the futures.
101-
///
102-
/// This function will take a list of futures (e.g. a vector, an iterator,
103-
/// etc), and return a stream. The stream will yield items as they become
104-
/// available on the futures internally, in the order that their originating
105-
/// futures were submitted to the queue. If the futures complete out of order,
106-
/// items will be stored internally within `FuturesOrdered` until all preceding
107-
/// items have been yielded.
108-
///
109-
/// Note that the returned queue can also be used to dynamically push more
110-
/// futures into the queue as they become available.
111-
pub fn futures_ordered<I>(futures: I) -> FuturesOrdered<I::Item>
112-
where
113-
I: IntoIterator,
114-
I::Item: Future,
115-
{
116-
futures.into_iter().collect()
117-
}
118-
119100
impl<Fut: Future> FuturesOrdered<Fut> {
120101
/// Constructs a new, empty `FuturesOrdered`
121102
///

futures-util/src/stream/futures_unordered/mod.rs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use alloc::sync::{Arc, Weak};
1919
mod abort;
2020

2121
mod iter;
22-
use self::iter::{IterMut, IterPinMut};
22+
pub use self::iter::{IterMut, IterPinMut};
2323

2424
mod task;
2525
use self::task::Task;
@@ -51,8 +51,8 @@ const TERMINATED_SENTINEL_LENGTH: usize = usize::max_value();
5151
/// wake-ups for new futures.
5252
///
5353
/// Note that you can create a ready-made [`FuturesUnordered`] via the
54-
/// [`futures_unordered`](futures_unordered()) function, or you can start with
55-
/// an empty set with the [`FuturesUnordered::new`] constructor.
54+
/// [`collect`](Iterator::collect) method, or you can start with an empty set
55+
/// with the [`FuturesUnordered::new`] constructor.
5656
#[must_use = "streams do nothing unless polled"]
5757
pub struct FuturesUnordered<Fut> {
5858
ready_to_run_queue: Arc<ReadyToRunQueue<Fut>>,
@@ -469,25 +469,6 @@ impl<Fut: Future> FromIterator<Fut> for FuturesUnordered<Fut> {
469469
}
470470
}
471471

472-
/// Converts a list of futures into a [`Stream`] of outputs from the futures.
473-
///
474-
/// This function will take a list of futures (e.g. a [`Vec`], an [`Iterator`],
475-
/// etc), and return a stream. The stream will yield items as they become
476-
/// available on the futures internally, in the order that they become
477-
/// available. This function is similar to
478-
/// [`buffer_unordered`](super::StreamExt::buffer_unordered) in that it may
479-
/// return items in a different order than in the list specified.
480-
///
481-
/// Note that the returned set can also be used to dynamically push more
482-
/// futures into the set as they become available.
483-
pub fn futures_unordered<I>(futures: I) -> FuturesUnordered<I::Item>
484-
where
485-
I: IntoIterator,
486-
I::Item: Future,
487-
{
488-
futures.into_iter().collect()
489-
}
490-
491472
impl<Fut: Future> FusedStream for FuturesUnordered<Fut> {
492473
fn is_terminated(&self) -> bool {
493474
self.len == TERMINATED_SENTINEL_LENGTH

futures-util/src/stream/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,13 @@ cfg_target_has_atomic! {
123123
#[cfg(feature = "alloc")]
124124
mod futures_ordered;
125125
#[cfg(feature = "alloc")]
126-
pub use self::futures_ordered::{futures_ordered, FuturesOrdered};
126+
pub use self::futures_ordered::FuturesOrdered;
127127

128128
#[cfg(feature = "alloc")]
129-
mod futures_unordered;
129+
pub mod futures_unordered;
130130
#[cfg(feature = "alloc")]
131-
pub use self::futures_unordered::{futures_unordered, FuturesUnordered};
131+
#[doc(inline)]
132+
pub use self::futures_unordered::FuturesUnordered;
132133

133134
#[cfg(feature = "alloc")]
134135
mod split;

futures/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,8 @@ pub mod stream {
322322
//! asynchronously produce a sequence of values.
323323
//! - The [`StreamExt`](crate::stream::StreamExt) trait, which provides
324324
//! adapters for chaining and composing streams.
325-
//! - Top-level stream contructors like [`iter_ok`](crate::stream::iter)
326-
//! which creates a stream from an iterator, and
327-
//! [`futures_unordered`](crate::stream::futures_unordered()), which
328-
//! constructs a stream from a collection of futures.
325+
//! - Top-level stream contructors like [`iter`](crate::stream::iter)
326+
//! which creates a stream from an iterator.
329327
330328
pub use futures_core::stream::{
331329
Stream, TryStream, FusedStream,
@@ -358,7 +356,7 @@ pub mod stream {
358356
)]
359357
#[cfg(feature = "alloc")]
360358
pub use futures_util::stream::{
361-
futures_ordered, FuturesOrdered,
359+
FuturesOrdered,
362360
futures_unordered, FuturesUnordered,
363361

364362
// For StreamExt:

0 commit comments

Comments
 (0)