Trait StreamExt

Source
pub trait StreamExt: Stream {
    // Provided methods
    fn map<T, F>(self, f: F) -> Map<Self, F>
       where F: FnMut(Self::Item) -> T,
             Self: Sized { ... }
    fn then<Fut, F>(self, f: F) -> Then<Self, F>
       where F: FnMut(Self::Item) -> Fut,
             Fut: Future,
             Self: Sized { ... }
    fn for_each<Fut, F>(self, f: F) -> impl Future<Output = ()>
       where F: FnMut(Self::Item) -> Fut,
             Fut: Future<Output = ()>,
             Self: Sized { ... }
}
Expand description

Stream extensions.

Provided Methods§

Source

fn map<T, F>(self, f: F) -> Map<Self, F>
where F: FnMut(Self::Item) -> T, Self: Sized,

Maps a stream to a stream of its items.

Source

fn then<Fut, F>(self, f: F) -> Then<Self, F>
where F: FnMut(Self::Item) -> Fut, Fut: Future, Self: Sized,

Computes from this stream’s items new items of a different type using an asynchronous closure.

Source

fn for_each<Fut, F>(self, f: F) -> impl Future<Output = ()>
where F: FnMut(Self::Item) -> Fut, Fut: Future<Output = ()>, Self: Sized,

Runs this stream to completion, executing the provided asynchronous closure for each element on the stream.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> StreamExt for T
where T: Stream,