From: Qi Date: Thu, 18 Dec 2025 11:21:59 +0000 (+0800) Subject: sync: clarify the cancellation safety of `oneshot::Receiver` (#7780) X-Git-Url: https://git.feebdaed.xyz/?a=commitdiff_plain;h=009a2567d0376d96ff3b459c5581057ab5b11770;p=0xmirror%2Ftokio.git sync: clarify the cancellation safety of `oneshot::Receiver` (#7780) Signed-off-by: ADD-SP Co-authored-by: Alice Ryhl --- diff --git a/tokio/src/sync/oneshot.rs b/tokio/src/sync/oneshot.rs index c5857f65..32e28844 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 /// /// ```