From e4ffc27bc669eaa199d39d9b05aa545b007b9ce3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 5 Nov 2016 11:21:39 -0700 Subject: [PATCH] Rename collect => join_all Closes #212 --- src/future/{collect.rs => join_all.rs} | 18 +++++++++--------- src/future/mod.rs | 11 +++++++++-- src/lib.rs | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) rename src/future/{collect.rs => join_all.rs} (90%) diff --git a/src/future/collect.rs b/src/future/join_all.rs similarity index 90% rename from src/future/collect.rs rename to src/future/join_all.rs index db91ccc4f91..97396e042d4 100644 --- a/src/future/collect.rs +++ b/src/future/join_all.rs @@ -1,4 +1,4 @@ -//! Definition of the Collect combinator, waiting for all of a list of futures +//! Definition of the JoinAll combinator, waiting for all of a list of futures //! to finish. use std::prelude::v1::*; @@ -10,9 +10,9 @@ use {Future, IntoFuture, Poll, Async}; /// A future which takes a list of futures and resolves with a vector of the /// completed values. /// -/// This future is created with the `collect` method. +/// This future is created with the `join_all` method. #[must_use = "futures do nothing unless polled"] -pub struct Collect +pub struct JoinAll where I: IntoIterator, I::Item: IntoFuture, { @@ -36,9 +36,9 @@ pub struct Collect /// # Examples /// /// ``` -/// use futures::*; +/// use futures::future::*; /// -/// let f = collect(vec![ +/// let f = join_all(vec![ /// finished::(1), /// finished::(2), /// finished::(3), @@ -47,7 +47,7 @@ pub struct Collect /// assert_eq!(x, [1, 2, 3]); /// }); /// -/// let f = collect(vec![ +/// let f = join_all(vec![ /// finished::(1).boxed(), /// failed::(2).boxed(), /// finished::(3).boxed(), @@ -57,19 +57,19 @@ pub struct Collect /// x /// }); /// ``` -pub fn collect(i: I) -> Collect +pub fn join_all(i: I) -> JoinAll where I: IntoIterator, I::Item: IntoFuture, { let mut i = i.into_iter(); - Collect { + JoinAll { cur: i.next().map(IntoFuture::into_future), remaining: i, result: Vec::new(), } } -impl Future for Collect +impl Future for JoinAll where I: IntoIterator, I::Item: IntoFuture, { diff --git a/src/future/mod.rs b/src/future/mod.rs index f2b61710a81..b4118ee50ff 100644 --- a/src/future/mod.rs +++ b/src/future/mod.rs @@ -45,14 +45,21 @@ pub use self::then::Then; if_std! { mod catch_unwind; - mod collect; + mod join_all; mod select_all; mod select_ok; pub use self::catch_unwind::CatchUnwind; - pub use self::collect::{collect, Collect}; + pub use self::join_all::{join_all, JoinAll}; pub use self::select_all::{SelectAll, SelectAllNext, select_all}; pub use self::select_ok::{SelectOk, select_ok}; + #[doc(hidden)] + #[deprecated(since = "0.1.4", note = "use join_all instead")] + pub use future::join_all as collect; + #[doc(hidden)] + #[deprecated(since = "0.1.4", note = "use JoinAll instead")] + pub use future::JoinAll as Collect; + /// A type alias for `Box` pub type BoxFuture = ::std::boxed::Box + Send>; diff --git a/src/lib.rs b/src/lib.rs index e381fd9104a..8b8636fb070 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -187,7 +187,7 @@ pub use future::{done, empty, failed, finished, lazy}; pub use future::{ Done, Empty, Failed, Finished, Lazy, AndThen, Flatten, FlattenStream, Fuse, IntoStream, Join, Join3, Join4, Join5, Map, MapErr, OrElse, Select, - SelectNext, Then + SelectNext, Then, Collect }; if_std! {