Skip to content

Commit 86be4a0

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

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-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

+1-15
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use std::cell::UnsafeCell;
1717
use std::marker::PhantomData;
1818
use std::mem;
19+
use std::process;
1920
use std::ptr;
2021
use std::sync::atomic::{self, AtomicUsize, Ordering};
2122
use std::time::Instant;
@@ -99,24 +100,9 @@ pub struct Channel<T> {
99100

100101
impl<T> Channel<T> {
101102
/// 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`.
106103
pub fn with_capacity(cap: usize) -> Self {
107104
assert!(cap > 0, "capacity must be positive");
108105

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-
120106
// Compute constants `mark_bit` and `one_lap`.
121107
let mark_bit = (cap + 1).next_power_of_two();
122108
let one_lap = mark_bit * 2;

0 commit comments

Comments
 (0)