pub trait JStreamExt: Stream + Sized {
// Provided methods
fn dedup(self) -> DedupStream<Self>
where Self::Item: Hash { ... }
fn fold_mut<T, F, Fut>(
self,
initial: T,
handler: F,
) -> FoldMut<Self, T, F, Fut> ⓘ
where Self: FusedStream,
F: FnMut(&mut T, Self::Item) -> Fut,
Fut: Future<Output = ()> { ... }
fn first(self) -> StreamNth<Self> ⓘ { ... }
fn nth(self, index: usize) -> StreamNth<Self> ⓘ { ... }
}Expand description
Provided Methods§
Sourcefn dedup(self) -> DedupStream<Self>
fn dedup(self) -> DedupStream<Self>
Given some stream where the item is Hash, return a stream which only emits the unique
items emitted by the source stream.
You can think of this as “de-duplicating” this stream. Only the first instance of every unique item will be emitted.
This is implemented by computing and storing the hash (a u64 value) in a HashSet for
each item emitted by the stream.
Sourcefn fold_mut<T, F, Fut>(self, initial: T, handler: F) -> FoldMut<Self, T, F, Fut> ⓘ
fn fold_mut<T, F, Fut>(self, initial: T, handler: F) -> FoldMut<Self, T, F, Fut> ⓘ
fold, but with mutable references.
Turns this stream into a Future<Output=T>. You must provide some initial value of type T,
and some function which accepts &mut T and Self::Item and returns Future<Output=()>.
After all items are emitted by this stream, the current value of T is emitted by the returned
future.
If the stream emits no values, then the initial value of T is emitted.
Sourcefn nth(self, index: usize) -> StreamNth<Self> ⓘ
fn nth(self, index: usize) -> StreamNth<Self> ⓘ
Turn this Stream into a Future which gives the
nth item emitted by this stream (in the form of an Option, because the stream doesn’t
have to emit enough items to reach the index n).
It will only emit exactly the n’th item. If the stream completes before the nth item
is reached, then the future will emit a value of None.
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.