futures_concurrency/stream/
into_stream.rs

1use futures_core::Stream;
2
3/// Conversion into a [`Stream`].
4///
5/// By implementing `IntoStream` for a type, you define how it will be
6/// converted to an iterator. This is common for types which describe a
7/// collection of some kind.
8pub trait IntoStream {
9    /// The type of the elements being iterated over.
10    type Item;
11
12    /// Which kind of stream are we turning this into?
13    type IntoStream: Stream<Item = Self::Item>;
14
15    /// Creates a stream from a value.
16    fn into_stream(self) -> Self::IntoStream;
17}
18
19impl<S: Stream> IntoStream for S {
20    type Item = S::Item;
21    type IntoStream = S;
22
23    #[inline]
24    fn into_stream(self) -> S {
25        self
26    }
27}