[][src]Trait parallel_stream::prelude::FromParallelStream

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
; }

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

Creates a value from a stream.

Loading content...

Implementations on Foreign Types

impl<T: Send> FromParallelStream<T> for Vec<T>[src]

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]);
}
Loading content...

Implementors

Loading content...