Skip to content

Commit d7d4f7d

Browse files
authored
sync: update broadcast docs on allocation failure (#7352)
1 parent 7ec77a0 commit d7d4f7d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tokio/src/sync/broadcast.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,10 @@ const MAX_RECEIVERS: usize = usize::MAX >> 2;
500500
///
501501
/// # Panics
502502
///
503-
/// This will panic if `capacity` is equal to `0` or larger
504-
/// than `usize::MAX / 2`.
503+
/// This will panic if `capacity` is equal to `0`.
504+
///
505+
/// This pre-allocates space for `capacity` messages. Allocation failure may result in a panic or
506+
/// [an allocation failure](std::alloc::handle_alloc_error).
505507
#[track_caller]
506508
pub fn channel<T: Clone>(capacity: usize) -> (Sender<T>, Receiver<T>) {
507509
// SAFETY: In the line below we are creating one extra receiver, so there will be 1 in total.

0 commit comments

Comments
 (0)