Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 0 additions & 117 deletions futures-util/src/future/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,6 @@ macro_rules! generate {
generate! {
/// Future for the [`join`](join()) function.
(Join, <Fut1, Fut2>),

/// Future for the [`join3`] function.
(Join3, <Fut1, Fut2, Fut3>),

/// Future for the [`join4`] function.
(Join4, <Fut1, Fut2, Fut3, Fut4>),

/// Future for the [`join5`] function.
(Join5, <Fut1, Fut2, Fut3, Fut4, Fut5>),
}

/// Joins the result of two futures, waiting for them both to complete.
Expand Down Expand Up @@ -116,111 +107,3 @@ where
let f = Join::new(future1, future2);
assert_future::<(Fut1::Output, Fut2::Output), _>(f)
}

/// Same as [`join`](join()), but with more futures.
///
/// # Examples
///
/// ```
/// # futures::executor::block_on(async {
/// use futures::future;
///
/// let a = async { 1 };
/// let b = async { 2 };
/// let c = async { 3 };
/// let tuple = future::join3(a, b, c);
///
/// assert_eq!(tuple.await, (1, 2, 3));
/// # });
/// ```
pub fn join3<Fut1, Fut2, Fut3>(
future1: Fut1,
future2: Fut2,
future3: Fut3,
) -> Join3<Fut1, Fut2, Fut3>
where
Fut1: Future,
Fut2: Future,
Fut3: Future,
{
let f = Join3::new(future1, future2, future3);
assert_future::<(Fut1::Output, Fut2::Output, Fut3::Output), _>(f)
}

/// Same as [`join`](join()), but with more futures.
///
/// # Examples
///
/// ```
/// # futures::executor::block_on(async {
/// use futures::future;
///
/// let a = async { 1 };
/// let b = async { 2 };
/// let c = async { 3 };
/// let d = async { 4 };
/// let tuple = future::join4(a, b, c, d);
///
/// assert_eq!(tuple.await, (1, 2, 3, 4));
/// # });
/// ```
pub fn join4<Fut1, Fut2, Fut3, Fut4>(
future1: Fut1,
future2: Fut2,
future3: Fut3,
future4: Fut4,
) -> Join4<Fut1, Fut2, Fut3, Fut4>
where
Fut1: Future,
Fut2: Future,
Fut3: Future,
Fut4: Future,
{
let f = Join4::new(future1, future2, future3, future4);
assert_future::<(Fut1::Output, Fut2::Output, Fut3::Output, Fut4::Output), _>(f)
}

/// Same as [`join`](join()), but with more futures.
///
/// # Examples
///
/// ```
/// # futures::executor::block_on(async {
/// use futures::future;
///
/// let a = async { 1 };
/// let b = async { 2 };
/// let c = async { 3 };
/// let d = async { 4 };
/// let e = async { 5 };
/// let tuple = future::join5(a, b, c, d, e);
///
/// assert_eq!(tuple.await, (1, 2, 3, 4, 5));
/// # });
/// ```
pub fn join5<Fut1, Fut2, Fut3, Fut4, Fut5>(
future1: Fut1,
future2: Fut2,
future3: Fut3,
future4: Fut4,
future5: Fut5,
) -> Join5<Fut1, Fut2, Fut3, Fut4, Fut5>
where
Fut1: Future,
Fut2: Future,
Fut3: Future,
Fut4: Future,
Fut5: Future,
{
let f = Join5::new(future1, future2, future3, future4, future5);
assert_future::<
(
Fut1::Output,
Fut2::Output,
Fut3::Output,
Fut4::Output,
Fut5::Output,
),
_,
>(f)
}
6 changes: 2 additions & 4 deletions futures-util/src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mod ready;
pub use self::ready::{err, ok, ready, Ready};

mod join;
pub use self::join::{join, join3, join4, join5, Join, Join3, Join4, Join5};
pub use self::join::{join, Join};

#[cfg(feature = "alloc")]
mod join_all;
Expand All @@ -88,9 +88,7 @@ mod select_all;
pub use self::select_all::{select_all, SelectAll};

mod try_join;
pub use self::try_join::{
try_join, try_join3, try_join4, try_join5, TryJoin, TryJoin3, TryJoin4, TryJoin5,
};
pub use self::try_join::{try_join, TryJoin};

#[cfg(feature = "alloc")]
mod try_join_all;
Expand Down
111 changes: 0 additions & 111 deletions futures-util/src/future/try_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,6 @@ macro_rules! generate {
generate! {
/// Future for the [`try_join`](try_join()) function.
(TryJoin, <Fut1, Fut2>),

/// Future for the [`try_join3`] function.
(TryJoin3, <Fut1, Fut2, Fut3>),

/// Future for the [`try_join4`] function.
(TryJoin4, <Fut1, Fut2, Fut3, Fut4>),

/// Future for the [`try_join5`] function.
(TryJoin5, <Fut1, Fut2, Fut3, Fut4, Fut5>),
}

/// Joins the result of two futures, waiting for them both to complete or
Expand Down Expand Up @@ -152,105 +143,3 @@ where
{
assert_future::<Result<(Fut1::Ok, Fut2::Ok), Fut1::Error>, _>(TryJoin::new(future1, future2))
}

/// Same as [`try_join`](try_join()), but with more futures.
///
/// # Examples
///
/// ```
/// # futures::executor::block_on(async {
/// use futures::future;
///
/// let a = future::ready(Ok::<i32, i32>(1));
/// let b = future::ready(Ok::<i32, i32>(2));
/// let c = future::ready(Ok::<i32, i32>(3));
/// let tuple = future::try_join3(a, b, c);
///
/// assert_eq!(tuple.await, Ok((1, 2, 3)));
/// # });
/// ```
pub fn try_join3<Fut1, Fut2, Fut3>(
future1: Fut1,
future2: Fut2,
future3: Fut3,
) -> TryJoin3<Fut1, Fut2, Fut3>
where
Fut1: TryFuture,
Fut2: TryFuture<Error = Fut1::Error>,
Fut3: TryFuture<Error = Fut1::Error>,
{
assert_future::<Result<(Fut1::Ok, Fut2::Ok, Fut3::Ok), Fut1::Error>, _>(TryJoin3::new(
future1, future2, future3,
))
}

/// Same as [`try_join`](try_join()), but with more futures.
///
/// # Examples
///
/// ```
/// # futures::executor::block_on(async {
/// use futures::future;
///
/// let a = future::ready(Ok::<i32, i32>(1));
/// let b = future::ready(Ok::<i32, i32>(2));
/// let c = future::ready(Ok::<i32, i32>(3));
/// let d = future::ready(Ok::<i32, i32>(4));
/// let tuple = future::try_join4(a, b, c, d);
///
/// assert_eq!(tuple.await, Ok((1, 2, 3, 4)));
/// # });
/// ```
pub fn try_join4<Fut1, Fut2, Fut3, Fut4>(
future1: Fut1,
future2: Fut2,
future3: Fut3,
future4: Fut4,
) -> TryJoin4<Fut1, Fut2, Fut3, Fut4>
where
Fut1: TryFuture,
Fut2: TryFuture<Error = Fut1::Error>,
Fut3: TryFuture<Error = Fut1::Error>,
Fut4: TryFuture<Error = Fut1::Error>,
{
assert_future::<Result<(Fut1::Ok, Fut2::Ok, Fut3::Ok, Fut4::Ok), Fut1::Error>, _>(
TryJoin4::new(future1, future2, future3, future4),
)
}

/// Same as [`try_join`](try_join()), but with more futures.
///
/// # Examples
///
/// ```
/// # futures::executor::block_on(async {
/// use futures::future;
///
/// let a = future::ready(Ok::<i32, i32>(1));
/// let b = future::ready(Ok::<i32, i32>(2));
/// let c = future::ready(Ok::<i32, i32>(3));
/// let d = future::ready(Ok::<i32, i32>(4));
/// let e = future::ready(Ok::<i32, i32>(5));
/// let tuple = future::try_join5(a, b, c, d, e);
///
/// assert_eq!(tuple.await, Ok((1, 2, 3, 4, 5)));
/// # });
/// ```
pub fn try_join5<Fut1, Fut2, Fut3, Fut4, Fut5>(
future1: Fut1,
future2: Fut2,
future3: Fut3,
future4: Fut4,
future5: Fut5,
) -> TryJoin5<Fut1, Fut2, Fut3, Fut4, Fut5>
where
Fut1: TryFuture,
Fut2: TryFuture<Error = Fut1::Error>,
Fut3: TryFuture<Error = Fut1::Error>,
Fut4: TryFuture<Error = Fut1::Error>,
Fut5: TryFuture<Error = Fut1::Error>,
{
assert_future::<Result<(Fut1::Ok, Fut2::Ok, Fut3::Ok, Fut4::Ok, Fut5::Ok), Fut1::Error>, _>(
TryJoin5::new(future1, future2, future3, future4, future5),
)
}
4 changes: 2 additions & 2 deletions futures/tests/sink_fanout.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use futures::channel::mpsc;
use futures::executor::block_on;
use futures::future::join3;
use futures::join;
use futures::sink::SinkExt;
use futures::stream::{self, StreamExt};

Expand All @@ -15,7 +15,7 @@ fn it_works() {

let collect_fut1 = rx1.collect::<Vec<_>>();
let collect_fut2 = rx2.collect::<Vec<_>>();
let (_, vec1, vec2) = block_on(join3(fwd, collect_fut1, collect_fut2));
let (_, vec1, vec2) = block_on(async move { join!(fwd, collect_fut1, collect_fut2)});

let expected = (0..10).collect::<Vec<_>>();

Expand Down