From d7d4f7d08bf75daf23bec676b03cb4c88993e5d0 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Sat, 24 May 2025 07:10:13 -0700 Subject: [PATCH] sync: update broadcast docs on allocation failure (#7352) --- tokio/src/sync/broadcast.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tokio/src/sync/broadcast.rs b/tokio/src/sync/broadcast.rs index fd77d837a..88ec57616 100644 --- a/tokio/src/sync/broadcast.rs +++ b/tokio/src/sync/broadcast.rs @@ -500,8 +500,10 @@ const MAX_RECEIVERS: usize = usize::MAX >> 2; /// /// # Panics /// -/// This will panic if `capacity` is equal to `0` or larger -/// than `usize::MAX / 2`. +/// This will panic if `capacity` is equal to `0`. +/// +/// This pre-allocates space for `capacity` messages. Allocation failure may result in a panic or +/// [an allocation failure](std::alloc::handle_alloc_error). #[track_caller] pub fn channel(capacity: usize) -> (Sender, Receiver) { // SAFETY: In the line below we are creating one extra receiver, so there will be 1 in total.