fn try_fold<T, Fut, F>(self, init: T, f: F) -> TryFold<Self, Fut, T, F>
    where
        F: FnMut(T, Self::Item) -> Fut,
        Fut: TryFuture<Ok = T>,
        Self: Sized,
    {
        assert_future::<Result<T, Fut::Error>, _>(TryFold::new(self, f, init))
    }
Attempt to execute an accumulating asynchronous computation over a
stream, collecting all the values into one final result.

This combinator will accumulate all values returned by this stream
according to the closure provided. The initial state is also provided to
this method and then is returned again by each execution of the closure.
Once the entire stream has been exhausted the returned future will
resolve to this value.

This method is similar to [`fold`](crate::stream::StreamExt::fold), but
will exit early if an error is encountered in the provided closure.

# Examples

```
# futures::executor::block_on(async {
use futures::stream::{self, StreamExt};

let number_stream = stream::iter(vec![1, 2]);
let sum = number_stream.try_fold(0, |acc, x| async move { Ok::<i32, i32>(acc + x) });
assert_eq!(sum.await, Ok(3));

let number_stream_with_err = stream::iter(vec![Ok::<i32, i32>(1), Err(2), Ok(1)]);
let sum = number_stream_with_err.try_fold(0, |acc, x| async move { Ok(acc + x?) });
assert_eq!(sum.await, Err(2));
# })
```
futures-util/src/stream/stream/mod.rs