Skip to main content

timely/dataflow/operators/vec/
to_stream.rs

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