pub trait Stream: StreamSource + Sized {
// Provided methods
fn map<U, F>(self, f: F) -> MapStream<Self, F>
where F: FnMut(Self::Item) -> U { ... }
fn filter<P>(self, pred: P) -> FilterStream<Self, P>
where P: FnMut(&Self::Item) -> bool { ... }
fn take(self, n: usize) -> TakeStream<Self> { ... }
fn skip(self, n: usize) -> SkipStream<Self> { ... }
fn flatten(self) -> FlattenStream<Self>
where Self::Item: IntoIterator { ... }
fn by_ref(&mut self) -> ByRefStream<'_, Self> { ... }
fn collect_stream(self) -> Vec<Self::Item> { ... }
fn count_stream(self) -> usize { ... }
fn for_each_stream<F: FnMut(Self::Item)>(self, f: F) { ... }
}Expand description
Full stream combinator trait.
Automatically implemented for any T: StreamSource + Sized. Provides the
ergonomic adaptor API (map, filter, take, etc.).
For boxed, type-erased streams use StreamSource directly or wrap in
BoxedStream.
Provided Methods§
Sourcefn filter<P>(self, pred: P) -> FilterStream<Self, P>
fn filter<P>(self, pred: P) -> FilterStream<Self, P>
Keep only items for which pred returns true.
Sourcefn take(self, n: usize) -> TakeStream<Self>
fn take(self, n: usize) -> TakeStream<Self>
Take at most n items then stop.
Sourcefn skip(self, n: usize) -> SkipStream<Self>
fn skip(self, n: usize) -> SkipStream<Self>
Skip the first n items then yield the rest.
Sourcefn flatten(self) -> FlattenStream<Self>where
Self::Item: IntoIterator,
fn flatten(self) -> FlattenStream<Self>where
Self::Item: IntoIterator,
Flatten a stream of iterables into a flat stream.
Sourcefn by_ref(&mut self) -> ByRefStream<'_, Self>
fn by_ref(&mut self) -> ByRefStream<'_, Self>
Borrow this stream mutably, producing an adaptor that forwards to it.
Sourcefn collect_stream(self) -> Vec<Self::Item>
fn collect_stream(self) -> Vec<Self::Item>
Collect all remaining items into a Vec.
Sourcefn count_stream(self) -> usize
fn count_stream(self) -> usize
Count remaining items (exhausts the stream).
Sourcefn for_each_stream<F: FnMut(Self::Item)>(self, f: F)
fn for_each_stream<F: FnMut(Self::Item)>(self, f: F)
Apply f to each item for its side-effects.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".