Skip to content

Commit

Permalink
Rename collect => join_all
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Nov 5, 2016
1 parent ed1a499 commit e4ffc27
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
18 changes: 9 additions & 9 deletions src/future/collect.rs → src/future/join_all.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand All @@ -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<I>
pub struct JoinAll<I>
where I: IntoIterator,
I::Item: IntoFuture,
{
Expand All @@ -36,9 +36,9 @@ pub struct Collect<I>
/// # Examples
///
/// ```
/// use futures::*;
/// use futures::future::*;
///
/// let f = collect(vec![
/// let f = join_all(vec![
/// finished::<u32, u32>(1),
/// finished::<u32, u32>(2),
/// finished::<u32, u32>(3),
Expand All @@ -47,7 +47,7 @@ pub struct Collect<I>
/// assert_eq!(x, [1, 2, 3]);
/// });
///
/// let f = collect(vec![
/// let f = join_all(vec![
/// finished::<u32, u32>(1).boxed(),
/// failed::<u32, u32>(2).boxed(),
/// finished::<u32, u32>(3).boxed(),
Expand All @@ -57,19 +57,19 @@ pub struct Collect<I>
/// x
/// });
/// ```
pub fn collect<I>(i: I) -> Collect<I>
pub fn join_all<I>(i: I) -> JoinAll<I>
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<I> Future for Collect<I>
impl<I> Future for JoinAll<I>
where I: IntoIterator,
I::Item: IntoFuture,
{
Expand Down
11 changes: 9 additions & 2 deletions src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Future + Send>`
pub type BoxFuture<T, E> = ::std::boxed::Box<Future<Item = T, Error = E> + Send>;

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down

0 comments on commit e4ffc27

Please sign in to comment.