diff --git a/crossbeam-channel/examples/stopwatch.rs b/crossbeam-channel/examples/stopwatch.rs index 3a7578e00..3a8962279 100644 --- a/crossbeam-channel/examples/stopwatch.rs +++ b/crossbeam-channel/examples/stopwatch.rs @@ -18,7 +18,7 @@ fn main() { // Creates a channel that gets a message every time `SIGINT` is signalled. fn sigint_notifier() -> io::Result> { let (s, r) = bounded(100); - let mut signals = Signals::new(&[SIGINT])?; + let mut signals = Signals::new([SIGINT])?; thread::spawn(move || { for _ in signals.forever() { diff --git a/crossbeam-channel/src/err.rs b/crossbeam-channel/src/err.rs index 18cb8307a..293e13b3a 100644 --- a/crossbeam-channel/src/err.rs +++ b/crossbeam-channel/src/err.rs @@ -200,18 +200,12 @@ impl TrySendError { /// Returns `true` if the send operation failed because the channel is full. pub fn is_full(&self) -> bool { - match self { - TrySendError::Full(_) => true, - _ => false, - } + matches!(self, TrySendError::Full(_)) } /// Returns `true` if the send operation failed because the channel is disconnected. pub fn is_disconnected(&self) -> bool { - match self { - TrySendError::Disconnected(_) => true, - _ => false, - } + matches!(self, TrySendError::Disconnected(_)) } } @@ -264,18 +258,12 @@ impl SendTimeoutError { /// Returns `true` if the send operation timed out. pub fn is_timeout(&self) -> bool { - match self { - SendTimeoutError::Timeout(_) => true, - _ => false, - } + matches!(self, SendTimeoutError::Timeout(_)) } /// Returns `true` if the send operation failed because the channel is disconnected. pub fn is_disconnected(&self) -> bool { - match self { - SendTimeoutError::Disconnected(_) => true, - _ => false, - } + matches!(self, SendTimeoutError::Disconnected(_)) } } @@ -309,18 +297,12 @@ impl From for TryRecvError { impl TryRecvError { /// Returns `true` if the receive operation failed because the channel is empty. pub fn is_empty(&self) -> bool { - match self { - TryRecvError::Empty => true, - _ => false, - } + matches!(self, TryRecvError::Empty) } /// Returns `true` if the receive operation failed because the channel is disconnected. pub fn is_disconnected(&self) -> bool { - match self { - TryRecvError::Disconnected => true, - _ => false, - } + matches!(self, TryRecvError::Disconnected) } } @@ -346,18 +328,12 @@ impl From for RecvTimeoutError { impl RecvTimeoutError { /// Returns `true` if the receive operation timed out. pub fn is_timeout(&self) -> bool { - match self { - RecvTimeoutError::Timeout => true, - _ => false, - } + matches!(self, RecvTimeoutError::Timeout) } /// Returns `true` if the receive operation failed because the channel is disconnected. pub fn is_disconnected(&self) -> bool { - match self { - RecvTimeoutError::Disconnected => true, - _ => false, - } + matches!(self, RecvTimeoutError::Disconnected) } } diff --git a/crossbeam-channel/src/select.rs b/crossbeam-channel/src/select.rs index 3eb0b97c8..f71069255 100644 --- a/crossbeam-channel/src/select.rs +++ b/crossbeam-channel/src/select.rs @@ -79,10 +79,10 @@ impl From for Selected { } } -impl Into for Selected { +impl From for usize { #[inline] - fn into(self) -> usize { - match self { + fn from(val: Selected) -> Self { + match val { Selected::Waiting => 0, Selected::Aborted => 1, Selected::Disconnected => 2, diff --git a/crossbeam-channel/tests/select_macro.rs b/crossbeam-channel/tests/select_macro.rs index ad10e99fe..c8b96c18d 100644 --- a/crossbeam-channel/tests/select_macro.rs +++ b/crossbeam-channel/tests/select_macro.rs @@ -965,6 +965,7 @@ fn references() { } } +#[allow(clippy::never_loop)] // This is intentional. #[test] fn case_blocks() { let (s, r) = unbounded::(); diff --git a/crossbeam-deque/src/deque.rs b/crossbeam-deque/src/deque.rs index c37de2dee..1356defb7 100644 --- a/crossbeam-deque/src/deque.rs +++ b/crossbeam-deque/src/deque.rs @@ -2056,10 +2056,7 @@ impl Steal { /// assert!(Empty::.is_empty()); /// ``` pub fn is_empty(&self) -> bool { - match self { - Steal::Empty => true, - _ => false, - } + matches!(self, Steal::Empty) } /// Returns `true` if at least one task was stolen. @@ -2075,10 +2072,7 @@ impl Steal { /// assert!(Success(7).is_success()); /// ``` pub fn is_success(&self) -> bool { - match self { - Steal::Success(_) => true, - _ => false, - } + matches!(self, Steal::Success(_)) } /// Returns `true` if the steal operation needs to be retried. @@ -2094,10 +2088,7 @@ impl Steal { /// assert!(Retry::.is_retry()); /// ``` pub fn is_retry(&self) -> bool { - match self { - Steal::Retry => true, - _ => false, - } + matches!(self, Steal::Retry) } /// Returns the result of the operation, if successful.