tests pass again

Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
pull/125/head
Yoshua Wuyts 5 years ago
parent 6c4c958abc
commit 6ee3f6cf9c
No known key found for this signature in database
GPG Key ID: 24EA8164F96777ED

@ -10,7 +10,7 @@ use std::pin::Pin;
/// See also: [`IntoStream`].
///
/// [`IntoStream`]: trait.IntoStream.html
pub trait FromStream<T> {
pub trait FromStream<T: Send> {
/// Creates a value from a stream.
///
/// # Examples
@ -22,7 +22,7 @@ pub trait FromStream<T> {
///
/// // 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,
) -> Pin<Box<dyn core::future::Future<Output = Self> + 'a>>;
) -> Pin<Box<dyn core::future::Future<Output = Self> + Send + 'a>>;
}

@ -18,13 +18,13 @@ pub trait IntoStream {
type Item;
/// 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.
fn into_stream(self) -> Self::IntoStream;
}
impl<I: Stream> IntoStream for I {
impl<I: Stream + Send> IntoStream for I {
type Item = I::Item;
type IntoStream = I;

@ -91,7 +91,7 @@ cfg_if! {
}
} else {
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:
///
/// ```
/// # fn main() { async_std::task::block_on(async {
/// #
/// use async_std::prelude::*;
@ -551,7 +552,6 @@ pub trait Stream {
///
/// let mut s = stream::repeat::<u32>(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,
<Self as futures_core::stream::Stream>::Item: Send,
B: FromStream<<Self as futures_core::stream::Stream>::Item>,
{
FromStream::from_stream(self)

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

Loading…
Cancel
Save