tests pass again

Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
This commit is contained in:
Yoshua Wuyts 2019-09-07 03:19:47 +02:00
parent 6c4c958abc
commit 6ee3f6cf9c
No known key found for this signature in database
GPG key ID: 24EA8164F96777ED
4 changed files with 12 additions and 11 deletions

View file

@ -10,7 +10,7 @@ use std::pin::Pin;
/// See also: [`IntoStream`]. /// See also: [`IntoStream`].
/// ///
/// [`IntoStream`]: trait.IntoStream.html /// [`IntoStream`]: trait.IntoStream.html
pub trait FromStream<T> { pub trait FromStream<T: Send> {
/// Creates a value from a stream. /// Creates a value from a stream.
/// ///
/// # Examples /// # Examples
@ -22,7 +22,7 @@ pub trait FromStream<T> {
/// ///
/// // let _five_fives = async_std::stream::repeat(5).take(5); /// // let _five_fives = async_std::stream::repeat(5).take(5);
/// ``` /// ```
fn from_stream<'a, S: IntoStream<Item = T> + 'a>( fn from_stream<'a, S: IntoStream<Item = T> + Send + 'a>(
stream: S, stream: S,
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>; ) -> Pin<Box<dyn core::future::Future<Output = Self> + Send + 'a>>;
} }

View file

@ -18,13 +18,13 @@ pub trait IntoStream {
type Item; type Item;
/// Which kind of stream are we turning this into? /// Which kind of stream are we turning this into?
type IntoStream: Stream<Item = Self::Item>; type IntoStream: Stream<Item = Self::Item> + Send;
/// Creates a stream from a value. /// Creates a stream from a value.
fn into_stream(self) -> Self::IntoStream; fn into_stream(self) -> Self::IntoStream;
} }
impl<I: Stream> IntoStream for I { impl<I: Stream + Send> IntoStream for I {
type Item = I::Item; type Item = I::Item;
type IntoStream = I; type IntoStream = I;

View file

@ -91,7 +91,7 @@ cfg_if! {
} }
} else { } else {
macro_rules! dyn_ret { macro_rules! dyn_ret {
($a:lifetime, $o:ty) => (Pin<Box<dyn core::future::Future<Output = $o> + 'a>>) ($a:lifetime, $o:ty) => (Pin<Box<dyn core::future::Future<Output = $o> + Send + 'a>>)
} }
} }
} }
@ -544,6 +544,7 @@ pub trait Stream {
/// ///
/// Basic usage: /// Basic usage:
/// ///
/// ```
/// # fn main() { async_std::task::block_on(async { /// # fn main() { async_std::task::block_on(async {
/// # /// #
/// use async_std::prelude::*; /// use async_std::prelude::*;
@ -551,7 +552,6 @@ pub trait Stream {
/// ///
/// let mut s = stream::repeat::<u32>(42).take(3); /// let mut s = stream::repeat::<u32>(42).take(3);
/// assert!(s.any(|x| x == 42).await); /// 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)"] #[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) fn collect<'a, B>(self) -> dyn_ret!('a, B)
where where
Self: futures_core::stream::Stream + Sized + 'a, Self: futures_core::stream::Stream + Sized + Send + 'a,
<Self as futures_core::stream::Stream>::Item: Send,
B: FromStream<<Self as futures_core::stream::Stream>::Item>, B: FromStream<<Self as futures_core::stream::Stream>::Item>,
{ {
FromStream::from_stream(self) FromStream::from_stream(self)

View file

@ -2,13 +2,13 @@ use crate::stream::{FromStream, IntoStream, Stream};
use std::pin::Pin; use std::pin::Pin;
impl<T> FromStream<T> for Vec<T> { impl<T: Send> FromStream<T> for Vec<T> {
#[inline] #[inline]
fn from_stream<'a, S: IntoStream<Item = T>>( fn from_stream<'a, S: IntoStream<Item = T>>(
stream: S, stream: S,
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>> ) -> Pin<Box<dyn core::future::Future<Output = Self> + Send + 'a>>
where where
<S as IntoStream>::IntoStream: 'a, <S as IntoStream>::IntoStream: Send + 'a,
{ {
let stream = stream.into_stream(); let stream = stream.into_stream();