Skip to content

Commit b3283e4

Browse files
author
Stjepan Glavina
committed
Remove unnecessary check in array.rs
1 parent e4b6ea7 commit b3283e4

File tree

2 files changed

+0
-19
lines changed

2 files changed

+0
-19
lines changed

crossbeam-channel/src/channel.rs

-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ pub fn unbounded<T>() -> (Sender<T>, Receiver<T>) {
5858
/// A special case is zero-capacity channel, which cannot hold any messages. Instead, send and
5959
/// receive operations must appear at the same time in order to pair up and pass the message over.
6060
///
61-
/// # Panics
62-
///
63-
/// Panics if the capacity is greater than `usize::max_value() / 4`.
64-
///
6561
/// # Examples
6662
///
6763
/// A channel of capacity 1:

crossbeam-channel/src/flavors/array.rs

-15
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,9 @@ pub struct Channel<T> {
9999

100100
impl<T> Channel<T> {
101101
/// Creates a bounded channel of capacity `cap`.
102-
///
103-
/// # Panics
104-
///
105-
/// Panics if the capacity is not in the range `1 ..= usize::max_value() / 4`.
106102
pub fn with_capacity(cap: usize) -> Self {
107103
assert!(cap > 0, "capacity must be positive");
108104

109-
// Make sure there are at least two most significant bits: one to encode laps and one more
110-
// to indicate that the channel is disconnected. If we can't reserve two bits, then panic.
111-
// In that case, the buffer is likely too large to allocate anyway.
112-
let cap_limit = usize::max_value() / 4;
113-
assert!(
114-
cap <= cap_limit,
115-
"channel capacity is too large: {} > {}",
116-
cap,
117-
cap_limit
118-
);
119-
120105
// Compute constants `mark_bit` and `one_lap`.
121106
let mark_bit = (cap + 1).next_power_of_two();
122107
let one_lap = mark_bit * 2;

0 commit comments

Comments
 (0)