fn try_collect<C: Default + Extend<Self::Ok>>(self) -> TryCollect<Self, C>
    where
        Self: Sized,
    {
        assert_future::<Result<C, Self::Error>, _>(TryCollect::new(self))
    }
Attempt to transform a stream into a collection,
returning a future representing the result of that computation.

This combinator will collect all successful results of this stream and
collect them into the specified collection type. If an error happens then all
collected elements will be dropped and the error will be returned.

The returned future will be resolved when the stream terminates.

# Examples

```
# futures::executor::block_on(async {
use futures::channel::mpsc;
use futures::stream::TryStreamExt;
use std::thread;

let (tx, rx) = mpsc::unbounded();

thread::spawn(move || {
for i in 1..=5 {
tx.unbounded_send(Ok(i)).unwrap();
}
tx.unbounded_send(Err(6)).unwrap();
});

let output: Result<Vec<i32>, i32> = rx.try_collect().await;
assert_eq!(output, Err(6));
# })
```
futures-util/src/stream/try_stream/mod.rs