timely/dataflow/operators/to_stream.rs
1//! Conversion to the `Stream` type from iterators.
2
3use crate::Data;
4use crate::dataflow::{Stream, Scope};
5use crate::dataflow::operators::core::{ToStream as ToStreamCore};
6
7/// Converts to a timely `Stream`.
8pub trait ToStream<D: Data> {
9 /// Converts to a timely `Stream`.
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).capture();
19 /// let data2 = vec![0,1,2].to_stream(scope).capture();
20 /// (data1, data2)
21 /// });
22 ///
23 /// assert_eq!(data1.extract(), data2.extract());
24 /// ```
25 fn to_stream<S: Scope>(self, scope: &mut S) -> Stream<S, D>;
26}
27
28impl<I: IntoIterator+'static> ToStream<I::Item> for I where I::Item: Data {
29 fn to_stream<S: Scope>(self, scope: &mut S) -> Stream<S, I::Item> {
30 ToStreamCore::to_stream(self, scope)
31 }
32}