diff --git a/tokio-stream/src/stream_ext.rs b/tokio-stream/src/stream_ext.rs index a7bc2044f..7f9501026 100644 --- a/tokio-stream/src/stream_ext.rs +++ b/tokio-stream/src/stream_ext.rs @@ -113,6 +113,12 @@ pub trait StreamExt: Stream { /// pinning it to the stack using the `pin_mut!` macro from the `pin_utils` /// crate. /// + /// # Cancel safety + /// + /// This method is cancel safe. The returned future only + /// holds onto a reference to the underlying stream, + /// so dropping it will never lose a value. + /// /// # Examples /// /// ``` @@ -149,6 +155,12 @@ pub trait StreamExt: Stream { /// an [`Option>`](Option), making for easy use /// with the [`?`](std::ops::Try) operator. /// + /// # Cancel safety + /// + /// This method is cancel safe. The returned future only + /// holds onto a reference to the underlying stream, + /// so dropping it will never lose a value. + /// /// # Examples /// /// ``` diff --git a/tokio-stream/src/stream_ext/next.rs b/tokio-stream/src/stream_ext/next.rs index 175490c48..706069fa6 100644 --- a/tokio-stream/src/stream_ext/next.rs +++ b/tokio-stream/src/stream_ext/next.rs @@ -8,6 +8,13 @@ use pin_project_lite::pin_project; pin_project! { /// Future for the [`next`](super::StreamExt::next) method. + /// + /// # Cancel safety + /// + /// This method is cancel safe. It only + /// holds onto a reference to the underlying stream, + /// so dropping it will never lose a value. + /// #[derive(Debug)] #[must_use = "futures do nothing unless you `.await` or poll them"] pub struct Next<'a, St: ?Sized> { diff --git a/tokio-stream/src/stream_ext/try_next.rs b/tokio-stream/src/stream_ext/try_next.rs index af27d87d8..93aa3bc15 100644 --- a/tokio-stream/src/stream_ext/try_next.rs +++ b/tokio-stream/src/stream_ext/try_next.rs @@ -9,6 +9,12 @@ use pin_project_lite::pin_project; pin_project! { /// Future for the [`try_next`](super::StreamExt::try_next) method. + /// + /// # Cancel safety + /// + /// This method is cancel safe. It only + /// holds onto a reference to the underlying stream, + /// so dropping it will never lose a value. #[derive(Debug)] #[must_use = "futures do nothing unless you `.await` or poll them"] pub struct TryNext<'a, St: ?Sized> {