mco/std/io/stream.rs
1/// stream is Iterator
2pub use Iterator as Stream;
3
4pub trait TryStream: Stream {
5 /// The type of successful values yielded by this future
6 type Ok;
7
8 /// The type of failures yielded by this future
9 type Error;
10
11 /// Poll this `TryStream` as if it were a `Stream`.
12 fn try_next(&mut self) -> Option<Result<Self::Ok, Self::Error>>;
13}
14
15impl<S, T, E> TryStream for S
16where
17 S: ?Sized + Stream<Item = Result<T, E>>,
18{
19 type Ok = T;
20 type Error = E;
21
22 fn try_next(&mut self) -> Option<Result<Self::Ok, Self::Error>> {
23 self.next()
24 }
25}