Skip to content

Commit

Permalink
sync: add panic docs for tokio::sync::broadcast::channel (#4622)
Browse files Browse the repository at this point in the history
  • Loading branch information
name1e5s authored Apr 17, 2022
1 parent c43832a commit 2fe49a6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tokio/src/sync/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Clone>(mut capacity: usize) -> (Sender<T>, Receiver<T>) {
assert!(capacity > 0, "capacity is empty");
assert!(capacity <= usize::MAX >> 1, "requested capacity too large");
Expand Down

0 comments on commit 2fe49a6

Please sign in to comment.