pub trait ReadyExt<Item>where
Self: Stream<Item = Item> + Sized,{
Show 13 methods
// Required methods
fn ready_all<F>(
self,
f: F,
) -> All<Self, Ready<bool>, impl FnMut(Item) -> Ready<bool>> ⓘ
where F: Fn(Item) -> bool;
fn ready_any<F>(
self,
f: F,
) -> Any<Self, Ready<bool>, impl FnMut(Item) -> Ready<bool>> ⓘ
where F: Fn(Item) -> bool;
fn ready_find<'a, F>(
self,
f: F,
) -> impl Future<Output = Option<Item>> + Send
where Self: Send + Unpin + 'a,
F: Fn(&Item) -> bool + Send + 'a,
Item: Send;
fn ready_find_map<'a, F, U>(
self,
f: F,
) -> impl Future<Output = Option<U>> + Send
where Self: Send + Unpin + 'a,
F: Fn(Item) -> Option<U> + Send + 'a,
Item: Send,
U: Send;
fn ready_filter<'a, F>(
self,
f: F,
) -> Filter<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
where F: Fn(&Item) -> bool + 'a;
fn ready_filter_map<F, U>(
self,
f: F,
) -> FilterMap<Self, Ready<Option<U>>, impl FnMut(Item) -> Ready<Option<U>>>
where F: Fn(Item) -> Option<U>;
fn ready_fold<T, F>(
self,
init: T,
f: F,
) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>> ⓘ
where F: Fn(T, Item) -> T;
fn ready_fold_default<T, F>(
self,
f: F,
) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>> ⓘ
where F: Fn(T, Item) -> T,
T: Default;
fn ready_for_each<F>(
self,
f: F,
) -> ForEach<Self, Ready<()>, impl FnMut(Item) -> Ready<()>> ⓘ
where F: FnMut(Item);
fn ready_take_while<'a, F>(
self,
f: F,
) -> TakeWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
where F: Fn(&Item) -> bool + 'a;
fn ready_scan<B, T, F>(
self,
init: T,
f: F,
) -> Scan<Self, T, Ready<Option<B>>, impl FnMut(&mut T, Item) -> Ready<Option<B>>>
where F: Fn(&mut T, Item) -> Option<B>;
fn ready_scan_each<T, F>(
self,
init: T,
f: F,
) -> Scan<Self, T, Ready<Option<Item>>, impl FnMut(&mut T, Item) -> Ready<Option<Item>>>
where F: Fn(&mut T, &Item);
fn ready_skip_while<'a, F>(
self,
f: F,
) -> SkipWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
where F: Fn(&Item) -> bool + 'a;
}Expand description
Adds synchronous counterparts to selected [StreamExt] combinators.
These methods accept ordinary closures for operations that do not need to await, avoiding an async block around iterator-like predicates and folds.
Required Methods§
Sourcefn ready_all<F>(
self,
f: F,
) -> All<Self, Ready<bool>, impl FnMut(Item) -> Ready<bool>> ⓘ
fn ready_all<F>( self, f: F, ) -> All<Self, Ready<bool>, impl FnMut(Item) -> Ready<bool>> ⓘ
Tests whether every item satisfies a synchronous predicate.
Evaluation stops at the first false result. An empty stream resolves to true.
Sourcefn ready_any<F>(
self,
f: F,
) -> Any<Self, Ready<bool>, impl FnMut(Item) -> Ready<bool>> ⓘ
fn ready_any<F>( self, f: F, ) -> Any<Self, Ready<bool>, impl FnMut(Item) -> Ready<bool>> ⓘ
Tests whether any item satisfies a synchronous predicate.
Evaluation stops at the first true result. An empty stream resolves to false.
Sourcefn ready_find<'a, F>(self, f: F) -> impl Future<Output = Option<Item>> + Send
fn ready_find<'a, F>(self, f: F) -> impl Future<Output = Option<Item>> + Send
Finds the first item satisfying a synchronous predicate.
Items are tested in source order and the first match is returned. The
future resolves to None when the stream ends without a match.
Sourcefn ready_find_map<'a, F, U>(
self,
f: F,
) -> impl Future<Output = Option<U>> + Send
fn ready_find_map<'a, F, U>( self, f: F, ) -> impl Future<Output = Option<U>> + Send
Finds the first value produced by a synchronous mapping predicate.
Items are mapped in source order until f returns Some. The future
resolves to None when every item maps to absence.
Sourcefn ready_filter<'a, F>(
self,
f: F,
) -> Filter<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
fn ready_filter<'a, F>( self, f: F, ) -> Filter<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
Retains items accepted by a synchronous predicate.
The predicate borrows each item as it is polled. Accepted items preserve their source order and value.
Sourcefn ready_filter_map<F, U>(
self,
f: F,
) -> FilterMap<Self, Ready<Option<U>>, impl FnMut(Item) -> Ready<Option<U>>>
fn ready_filter_map<F, U>( self, f: F, ) -> FilterMap<Self, Ready<Option<U>>, impl FnMut(Item) -> Ready<Option<U>>>
Maps items synchronously while filtering absent results.
Values returned in Some are yielded in source order. Items mapped to
None are discarded.
Sourcefn ready_fold<T, F>(
self,
init: T,
f: F,
) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>> ⓘwhere
F: Fn(T, Item) -> T,
fn ready_fold<T, F>(
self,
init: T,
f: F,
) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>> ⓘwhere
F: Fn(T, Item) -> T,
Folds items synchronously from an explicit initial accumulator.
f receives the accumulator and each item in source order. The future
resolves to the final accumulator after the stream ends.
Sourcefn ready_fold_default<T, F>(
self,
f: F,
) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>> ⓘ
fn ready_fold_default<T, F>( self, f: F, ) -> Fold<Self, Ready<T>, T, impl FnMut(T, Item) -> Ready<T>> ⓘ
Folds items synchronously from T::default().
f receives the accumulator and each item in source order. An empty
stream resolves to the default accumulator unchanged.
Sourcefn ready_for_each<F>(
self,
f: F,
) -> ForEach<Self, Ready<()>, impl FnMut(Item) -> Ready<()>> ⓘwhere
F: FnMut(Item),
fn ready_for_each<F>(
self,
f: F,
) -> ForEach<Self, Ready<()>, impl FnMut(Item) -> Ready<()>> ⓘwhere
F: FnMut(Item),
Applies a synchronous closure to every stream item.
Items are consumed in source order. The returned future resolves after the stream ends and carries no output value.
Sourcefn ready_take_while<'a, F>(
self,
f: F,
) -> TakeWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
fn ready_take_while<'a, F>( self, f: F, ) -> TakeWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
Yields the leading items accepted by a synchronous predicate.
Evaluation stops at the first false result, and that boundary item is not yielded. Accepted items retain source order.
Sourcefn ready_scan<B, T, F>(
self,
init: T,
f: F,
) -> Scan<Self, T, Ready<Option<B>>, impl FnMut(&mut T, Item) -> Ready<Option<B>>>
fn ready_scan<B, T, F>( self, init: T, f: F, ) -> Scan<Self, T, Ready<Option<B>>, impl FnMut(&mut T, Item) -> Ready<Option<B>>>
Transforms items with mutable state and a synchronous scan closure.
Each Some result is yielded while None terminates the stream. State
is initialized once and retained between items.
Sourcefn ready_scan_each<T, F>(
self,
init: T,
f: F,
) -> Scan<Self, T, Ready<Option<Item>>, impl FnMut(&mut T, Item) -> Ready<Option<Item>>>
fn ready_scan_each<T, F>( self, init: T, f: F, ) -> Scan<Self, T, Ready<Option<Item>>, impl FnMut(&mut T, Item) -> Ready<Option<Item>>>
Observes each item with mutable state and yields it unchanged.
The closure receives the persistent state and a shared reference to each item. Every source item is then emitted in order.
Sourcefn ready_skip_while<'a, F>(
self,
f: F,
) -> SkipWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
fn ready_skip_while<'a, F>( self, f: F, ) -> SkipWhile<Self, Ready<bool>, impl FnMut(&Item) -> Ready<bool> + 'a>
Skips the leading items accepted by a synchronous predicate.
The first false item and every later item are yielded in source order. The predicate is no longer called after the first false result.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".