timely/dataflow/operators/vec/to_stream.rs
1//! Conversion to the `StreamVec` type from iterators.
2
3use crate::dataflow::{StreamVec, Scope};
4use crate::progress::Timestamp;
5use crate::dataflow::operators::core::{ToStream as ToStreamCore};
6
7/// Converts to a timely `StreamVec`.
8pub trait ToStream<D: 'static> {
9 /// Converts to a timely `StreamVec`.
10 ///
11 /// # Examples
12 ///
13 /// ```
14 /// use timely::dataflow::operators::{ToStream, Capture};
15 /// use timely::dataflow::operators::capture::Extract;
16 ///
17 /// let (data1, data2) = timely::example(|scope| {
18 /// let data1 = (0..3).to_stream(scope).container::<Vec<_>>().capture();
19 /// let data2 = vec![0,1,2].to_stream(scope).container::<Vec<_>>().capture();
20 /// (data1, data2)
21 /// });
22 ///
23 /// assert_eq!(data1.extract(), data2.extract());
24 /// ```
25 fn to_stream<'scope, T: Timestamp>(self, scope: Scope<'scope, T>) -> StreamVec<'scope, T, D>;
26}
27
28impl<I: IntoIterator+'static> ToStream<I::Item> for I {
29 fn to_stream<'scope, T: Timestamp>(self, scope: Scope<'scope, T>) -> StreamVec<'scope, T, I::Item> {
30 ToStreamCore::to_stream(self, scope)
31 }
32}