Trait parallel_stream::FromParallelStream [−][src]
pub trait FromParallelStream<T: Send> {
fn from_par_stream<'a, S>(
stream: S
) -> Pin<Box<dyn Future<Output = Self> + Send + 'a>>
where
S: IntoParallelStream<Item = T> + 'a + Send;
}
Expand description
Conversion from a ParallelStream
.
Required methods
fn from_par_stream<'a, S>(
stream: S
) -> Pin<Box<dyn Future<Output = Self> + Send + 'a>> where
S: IntoParallelStream<Item = T> + 'a + Send,
fn from_par_stream<'a, S>(
stream: S
) -> Pin<Box<dyn Future<Output = Self> + Send + 'a>> where
S: IntoParallelStream<Item = T> + 'a + Send,
Creates a value from a stream.
Implementations on Foreign Types
Collect items from a parallel stream into a vector.
Examples
use parallel_stream::prelude::*;
#[async_std::main]
async fn main() {
let v = vec![1, 2, 3, 4];
let mut stream = v.into_par_stream().map(|n| async move { n * n });
let mut res = Vec::from_par_stream(stream).await;
res.sort();
assert_eq!(res, vec![1, 4, 9, 16]);
}