Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Nov 5, 2023
1 parent 7b4b1e9 commit 2842cad
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 48 deletions.
2 changes: 1 addition & 1 deletion crossbeam-channel/examples/stopwatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
// Creates a channel that gets a message every time `SIGINT` is signalled.
fn sigint_notifier() -> io::Result<Receiver<()>> {
let (s, r) = bounded(100);
let mut signals = Signals::new(&[SIGINT])?;
let mut signals = Signals::new([SIGINT])?;

thread::spawn(move || {
for _ in signals.forever() {
Expand Down
40 changes: 8 additions & 32 deletions crossbeam-channel/src/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,12 @@ impl<T> TrySendError<T> {

/// 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(_))
}
}

Expand Down Expand Up @@ -264,18 +258,12 @@ impl<T> SendTimeoutError<T> {

/// 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(_))
}
}

Expand Down Expand Up @@ -309,18 +297,12 @@ impl From<RecvError> 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)
}
}

Expand All @@ -346,18 +328,12 @@ impl From<RecvError> 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)
}
}

Expand Down
6 changes: 3 additions & 3 deletions crossbeam-channel/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ impl From<usize> for Selected {
}
}

impl Into<usize> for Selected {
impl From<Selected> 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,
Expand Down
1 change: 1 addition & 0 deletions crossbeam-channel/tests/select_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ fn references() {
}
}

#[allow(clippy::never_loop)] // This is intentional.
#[test]
fn case_blocks() {
let (s, r) = unbounded::<i32>();
Expand Down
15 changes: 3 additions & 12 deletions crossbeam-deque/src/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2056,10 +2056,7 @@ impl<T> Steal<T> {
/// assert!(Empty::<i32>.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.
Expand All @@ -2075,10 +2072,7 @@ impl<T> Steal<T> {
/// 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.
Expand All @@ -2094,10 +2088,7 @@ impl<T> Steal<T> {
/// assert!(Retry::<i32>.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.
Expand Down

0 comments on commit 2842cad

Please sign in to comment.