From 6ee3f6cf9c9fece9f36af390f869b324dfd95663 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Sat, 7 Sep 2019 03:19:47 +0200 Subject: [PATCH] tests pass again Signed-off-by: Yoshua Wuyts --- src/stream/from_stream.rs | 6 +++--- src/stream/into_stream.rs | 4 ++-- src/stream/stream/mod.rs | 7 ++++--- src/vec/from_stream.rs | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/stream/from_stream.rs b/src/stream/from_stream.rs index 8b9ad262..7a262f7a 100644 --- a/src/stream/from_stream.rs +++ b/src/stream/from_stream.rs @@ -10,7 +10,7 @@ use std::pin::Pin; /// See also: [`IntoStream`]. /// /// [`IntoStream`]: trait.IntoStream.html -pub trait FromStream { +pub trait FromStream { /// Creates a value from a stream. /// /// # Examples @@ -22,7 +22,7 @@ pub trait FromStream { /// /// // let _five_fives = async_std::stream::repeat(5).take(5); /// ``` - fn from_stream<'a, S: IntoStream + 'a>( + fn from_stream<'a, S: IntoStream + Send + 'a>( stream: S, - ) -> Pin + 'a>>; + ) -> Pin + Send + 'a>>; } diff --git a/src/stream/into_stream.rs b/src/stream/into_stream.rs index 63fb558d..42f95299 100644 --- a/src/stream/into_stream.rs +++ b/src/stream/into_stream.rs @@ -18,13 +18,13 @@ pub trait IntoStream { type Item; /// Which kind of stream are we turning this into? - type IntoStream: Stream; + type IntoStream: Stream + Send; /// Creates a stream from a value. fn into_stream(self) -> Self::IntoStream; } -impl IntoStream for I { +impl IntoStream for I { type Item = I::Item; type IntoStream = I; diff --git a/src/stream/stream/mod.rs b/src/stream/stream/mod.rs index 88b54520..529b7cfb 100644 --- a/src/stream/stream/mod.rs +++ b/src/stream/stream/mod.rs @@ -91,7 +91,7 @@ cfg_if! { } } else { macro_rules! dyn_ret { - ($a:lifetime, $o:ty) => (Pin + 'a>>) + ($a:lifetime, $o:ty) => (Pin + Send + 'a>>) } } } @@ -544,6 +544,7 @@ pub trait Stream { /// /// Basic usage: /// + /// ``` /// # fn main() { async_std::task::block_on(async { /// # /// use async_std::prelude::*; @@ -551,7 +552,6 @@ pub trait Stream { /// /// let mut s = stream::repeat::(42).take(3); /// assert!(s.any(|x| x == 42).await); - /// /// # /// # }) } /// ``` @@ -704,7 +704,8 @@ pub trait Stream { #[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead (TODO)"] fn collect<'a, B>(self) -> dyn_ret!('a, B) where - Self: futures_core::stream::Stream + Sized + 'a, + Self: futures_core::stream::Stream + Sized + Send + 'a, + ::Item: Send, B: FromStream<::Item>, { FromStream::from_stream(self) diff --git a/src/vec/from_stream.rs b/src/vec/from_stream.rs index ce2afc50..f603d0dc 100644 --- a/src/vec/from_stream.rs +++ b/src/vec/from_stream.rs @@ -2,13 +2,13 @@ use crate::stream::{FromStream, IntoStream, Stream}; use std::pin::Pin; -impl FromStream for Vec { +impl FromStream for Vec { #[inline] fn from_stream<'a, S: IntoStream>( stream: S, - ) -> Pin + 'a>> + ) -> Pin + Send + 'a>> where - ::IntoStream: 'a, + ::IntoStream: Send + 'a, { let stream = stream.into_stream();