Function async_utils::fold::fold_while

source ยท
pub fn fold_while<S, T, D, F, Fut>(
    s: S,
    init: T,
    f: F,
) -> impl Future<Output = FoldResult<T, D>>
where S: Stream, F: FnMut(T, S::Item) -> Fut, Fut: Future<Output = FoldWhile<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.