[−][src]Function gabelung::new
pub fn new<S: Stream>(stream: S) -> (Branch<S, S::Item>, Branch<S, S::Item>)
Branch the given stream into two.
This creates two handles which can be polled independently from each other and
will receive all items from the underlying stream (which must be Clone
).
As long as both halves are alive, one half will never outpace the other by more than a fixed number of items.
Example
use futures::{stream, prelude::*}; let (mut left, mut right) = gabelung::new(stream::repeat(1u8)); assert_eq!(left.next().await, Some(1u8)); assert_eq!(right.next().await, Some(1u8));