sync: add panic docs for tokio::sync::broadcast::channel (#4622)

This commit is contained in:
Name1e5s
2022-04-17 13:34:51 +02:00
committed by GitHub
parent c43832a7b1
commit 2fe49a68a4
+5
View File
@@ -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");