pub fn fold_while<S, T, D, F, Fut>(
s: S,
init: T,
f: F,
) -> impl Future<Output = FoldResult<T, D>>
Expand description
Similar to [StreamExt::fold
], but the closure f
can short-circuit
the operation by returning FoldWhile::Done
.
Returns FoldResult::StreamEnded
with the current folded value when the
stream ends. Returns FoldResult::ShortCircuited
with the value of
FoldWhile::Done
if f
short-circuits the operation.