File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ use 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( any( feature = "unstable" , feature = "docs" ) ) ]
18+ #[ cfg_attr( feature = "docs" , doc( cfg( unstable) ) ) ]
19+ pub trait FusedStream : Stream { }
20+
21+ impl < S : FusedStream + ?Sized + Unpin > FusedStream for & mut S { }
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ mod repeat;
3737cfg_if ! {
3838 if #[ cfg( any( feature = "unstable" , feature = "docs" ) ) ] {
3939 mod double_ended_stream;
40+ mod fused_stream;
4041 mod extend;
4142 mod from_stream;
4243 mod into_stream;
@@ -45,6 +46,7 @@ cfg_if! {
4546 pub use extend:: Extend ;
4647 pub use from_stream:: FromStream ;
4748 pub use into_stream:: IntoStream ;
49+ pub use fused_stream:: FusedStream ;
4850
4951 pub use stream:: Merge ;
5052 }
You can’t perform that action at this time.
0 commit comments