async_std/stream/fused_stream.rs
1use crate::stream::Stream;
2
3/// A stream that always continues to yield `None` when exhausted.
4///
5/// Calling next on a fused stream that has returned `None` once is guaranteed
6/// to return [`None`] again. This trait should be implemented by all streams
7/// that behave this way because it allows optimizing [`Stream::fuse`].
8///
9/// Note: In general, you should not use `FusedStream` in generic bounds if
10/// you need a fused stream. Instead, you should just call [`Stream::fuse`]
11/// on the stream. If the stream is already fused, the additional [`Fuse`]
12/// wrapper will be a no-op with no performance penalty.
13///
14/// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None
15/// [`Stream::fuse`]: trait.Stream.html#method.fuse
16/// [`Fuse`]: struct.Fuse.html
17#[cfg(feature = "unstable")]
18#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
19pub trait FusedStream: Stream {}
20
21impl<S: FusedStream + ?Sized + Unpin> FusedStream for &mut S {}