pub trait FromParallelStream<T: Send> {
// Required method
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§
Sourcefn 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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<T: Send> FromParallelStream<T> for Vec<T>
Collect items from a parallel stream into a vector.
impl<T: Send> FromParallelStream<T> for Vec<T>
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]);
}