[−][src]Trait flood::IntoStream
Conversion into an Stream
.
By implementing IntoStream for a type, you define how it will be converted to a Stream
.
This is the Stream
trait parallel to IntoIterator
for Iterator
s.
A note of caution is to not implement generic methods for this like you'd for IntoIterator
because without specialization it's not currently possible to blanket implement this for all Stream
s
Associated Types
type Item
The type of the elements being streamed.
type IntoStream: Stream<Item = Self::Item>
Which kind of stream are we turning this into?
Required methods
fn into_stream(self) -> Self::IntoStream
Creates a stream from a value.
Examples
Basic usage:
use flood::IntoStream; use futures_util::stream::StreamExt; #[tokio::main] async fn main() { let v = vec![1, 2, 3]; let mut stream = v.into_stream(); assert_eq!(Some(1), stream.next().await); assert_eq!(Some(2), stream.next().await); assert_eq!(Some(3), stream.next().await); assert_eq!(None, stream.next().await); }
Implementors
impl<T> IntoStream for T where
T: IntoIterator,
[src]
T: IntoIterator,