pub trait StreamTools: Stream {
    fn zip_latest_with<S, F, T>(
        self,
        other: S,
        combine: F
    ) -> ZipLatestWith<Self, S, F>
    where
        Self: Sized,
        S: Stream,
        F: FnMut(&Self::Item, &S::Item) -> T
, { ... } fn zip_latest<S>(self, other: S) -> ZipLatest<Self, S>
    where
        Self: Sized,
        Self::Item: Clone,
        S: Stream,
        S::Item: Clone
, { ... } }
Expand description

Extension trait for Stream.

Provided Methods

Zips two streams using their latest values when one is not ready

The zipped stream keeps the latest items produced by both streams. If one of the underlying streams is exhausted or not ready and the other stream yields a new item, it is combined with the latest item from the stream that did not yield anything new.

The zipped stream ends when both underlying streams end, or if one of the streams ends without ever producing an item.

Visually, this gives:

---0-----------1-----------------2-------> self
------10-------11-------12---------------> other
------10-------12-------13-------14------> self.zip_latest_with(other, |a, b| a + b)

Zips two streams using their latest values when one is not ready

The zipped stream keeps a copy of the latest items produced by both streams. If one of the underlying streams is exhausted or not ready and the other stream yields a new item, it is returned alongside the latest item from the stream that did not yield anything new.

The zipped stream ends when both underlying streams end, or if one of the streams ends without ever producing an item.

Visually, this gives:

---a-----------b-----------------c-------> self
------0--------1--------2----------------> other
------(a, 0)---(b, 1)---(b, 2)---(c, 2)--> self.zip_latest(other)

Implementors