File tree 2 files changed +0
-19
lines changed
2 files changed +0
-19
lines changed Original file line number Diff line number Diff line change @@ -58,10 +58,6 @@ pub fn unbounded<T>() -> (Sender<T>, Receiver<T>) {
58
58
/// A special case is zero-capacity channel, which cannot hold any messages. Instead, send and
59
59
/// receive operations must appear at the same time in order to pair up and pass the message over.
60
60
///
61
- /// # Panics
62
- ///
63
- /// Panics if the capacity is greater than `usize::max_value() / 4`.
64
- ///
65
61
/// # Examples
66
62
///
67
63
/// A channel of capacity 1:
Original file line number Diff line number Diff line change @@ -99,24 +99,9 @@ pub struct Channel<T> {
99
99
100
100
impl < T > Channel < T > {
101
101
/// 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`.
106
102
pub fn with_capacity ( cap : usize ) -> Self {
107
103
assert ! ( cap > 0 , "capacity must be positive" ) ;
108
104
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
-
120
105
// Compute constants `mark_bit` and `one_lap`.
121
106
let mark_bit = ( cap + 1 ) . next_power_of_two ( ) ;
122
107
let one_lap = mark_bit * 2 ;
You can’t perform that action at this time.
0 commit comments