From 794e331761634ef6c89f8f57fd409fa415e0521c Mon Sep 17 00:00:00 2001 From: nasa Date: Wed, 27 Nov 2019 21:38:38 +0900 Subject: [PATCH] Refactor join type (#577) * refactor: update future join type * test: update future join test * update future::try_join --- src/future/future/join.rs | 6 +++--- src/future/future/mod.rs | 20 ++++++++++---------- src/future/future/try_join.rs | 12 ++++++------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/future/future/join.rs b/src/future/future/join.rs index 5cfbd99..0febcad 100644 --- a/src/future/future/join.rs +++ b/src/future/future/join.rs @@ -12,7 +12,7 @@ pin_project! { pub struct Join where L: Future, - R: Future + R: Future, { #[pin] left: MaybeDone, #[pin] right: MaybeDone, @@ -22,7 +22,7 @@ pin_project! { impl Join where L: Future, - R: Future, + R: Future, { pub(crate) fn new(left: L, right: R) -> Self { Self { @@ -35,7 +35,7 @@ where impl Future for Join where L: Future, - R: Future, + R: Future, { type Output = (L::Output, R::Output); diff --git a/src/future/future/mod.rs b/src/future/future/mod.rs index 5fdaf4b..0f9ef58 100644 --- a/src/future/future/mod.rs +++ b/src/future/future/mod.rs @@ -289,10 +289,10 @@ extension_trait! { use async_std::future; let a = future::ready(1u8); - let b = future::ready(2u8); + let b = future::ready(2u16); let f = a.join(b); - assert_eq!(f.await, (1u8, 2u8)); + assert_eq!(f.await, (1u8, 2u16)); # }); ``` "#] @@ -304,7 +304,7 @@ extension_trait! { ) -> impl Future::Output, ::Output)> [Join] where Self: std::future::Future + Sized, - F: std::future::Future::Output>, + F: std::future::Future, { Join::new(self, other) } @@ -328,30 +328,30 @@ extension_trait! { use async_std::prelude::*; use async_std::future; - let a = future::ready(Err("Error")); + let a = future::ready(Err::("Error")); let b = future::ready(Ok(1u8)); let f = a.try_join(b); assert_eq!(f.await, Err("Error")); let a = future::ready(Ok::(1u8)); - let b = future::ready(Ok::(2u8)); + let b = future::ready(Ok::(2u16)); let f = a.try_join(b); - assert_eq!(f.await, Ok((1u8, 2u8))); + assert_eq!(f.await, Ok((1u8, 2u16))); # # Ok(()) }) } ``` "#] #[cfg(any(feature = "unstable", feature = "docs"))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))] - fn try_join( + fn try_join( self, other: F - ) -> impl Future> [TryJoin] + ) -> impl Future> [TryJoin] where - Self: std::future::Future> + Sized, - F: std::future::Future::Output>, + Self: std::future::Future> + Sized, + F: std::future::Future>, { TryJoin::new(self, other) } diff --git a/src/future/future/try_join.rs b/src/future/future/try_join.rs index 58ae6d6..f166724 100644 --- a/src/future/future/try_join.rs +++ b/src/future/future/try_join.rs @@ -12,7 +12,7 @@ pin_project! { pub struct TryJoin where L: Future, - R: Future + R: Future, { #[pin] left: MaybeDone, #[pin] right: MaybeDone, @@ -22,7 +22,7 @@ pin_project! { impl TryJoin where L: Future, - R: Future, + R: Future, { pub(crate) fn new(left: L, right: R) -> Self { Self { @@ -32,12 +32,12 @@ where } } -impl Future for TryJoin +impl Future for TryJoin where - L: Future>, - R: Future, + L: Future>, + R: Future>, { - type Output = Result<(T, T), E>; + type Output = Result<(A, B), E>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project();