From 2fe49a68a4463acc5a4129228acd852dff6a7178 Mon Sep 17 00:00:00 2001 From: Name1e5s Date: Sun, 17 Apr 2022 19:34:51 +0800 Subject: [PATCH] sync: add panic docs for `tokio::sync::broadcast::channel` (#4622) --- tokio/src/sync/broadcast.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tokio/src/sync/broadcast.rs b/tokio/src/sync/broadcast.rs index e54fe5c8151..846d6c027a6 100644 --- a/tokio/src/sync/broadcast.rs +++ b/tokio/src/sync/broadcast.rs @@ -425,6 +425,11 @@ const MAX_RECEIVERS: usize = usize::MAX >> 2; /// tx.send(20).unwrap(); /// } /// ``` +/// +/// # Panics +/// +/// This will panic if `capacity` is equal to `0` or larger +/// than `usize::MAX / 2`. pub fn channel(mut capacity: usize) -> (Sender, Receiver) { assert!(capacity > 0, "capacity is empty"); assert!(capacity <= usize::MAX >> 1, "requested capacity too large");