From 009a2567d0376d96ff3b459c5581057ab5b11770 Mon Sep 17 00:00:00 2001 From: Qi Date: Thu, 18 Dec 2025 19:21:59 +0800 Subject: [PATCH] sync: clarify the cancellation safety of `oneshot::Receiver` (#7780) Signed-off-by: ADD-SP Co-authored-by: Alice Ryhl --- tokio/src/sync/oneshot.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tokio/src/sync/oneshot.rs b/tokio/src/sync/oneshot.rs index c5857f654..32e288442 100644 --- a/tokio/src/sync/oneshot.rs +++ b/tokio/src/sync/oneshot.rs @@ -243,6 +243,13 @@ pub struct Sender { /// /// [`Future`]: trait@std::future::Future /// +/// # Cancellation safety +/// +/// The `Receiver` is cancel safe. If it is used as the event in a +/// [`tokio::select!`](crate::select) statement and some other branch +/// completes first, it is guaranteed that no message was received on this +/// channel. +/// /// # Examples /// /// ```