Skip to content

Commit 374c5cd

Browse files
committed
Fix clippy::bool_to_int_with_if warning
``` warning: boolean to int conversion using if --> crossbeam-channel/src/flavors/at.rs:137:9 | 137 | / if self.is_empty() { 138 | | 0 139 | | } else { 140 | | 1 141 | | } | |_________^ help: replace with from: `usize::from(!self.is_empty())` | = note: `!self.is_empty() as usize` or `(!self.is_empty()).into()` can also be valid options = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_to_int_with_if = note: `#[warn(clippy::bool_to_int_with_if)]` on by default warning: boolean to int conversion using if --> crossbeam-channel/src/flavors/tick.rs:108:9 | 108 | / if self.is_empty() { 109 | | 0 110 | | } else { 111 | | 1 112 | | } | |_________^ help: replace with from: `usize::from(!self.is_empty())` | = note: `!self.is_empty() as usize` or `(!self.is_empty()).into()` can also be valid options = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_to_int_with_if ```
1 parent 0de660e commit 374c5cd

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

crossbeam-channel/src/flavors/at.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,7 @@ impl Channel {
134134
/// Returns the number of messages in the channel.
135135
#[inline]
136136
pub(crate) fn len(&self) -> usize {
137-
if self.is_empty() {
138-
0
139-
} else {
140-
1
141-
}
137+
usize::from(!self.is_empty())
142138
}
143139

144140
/// Returns the capacity of the channel.

crossbeam-channel/src/flavors/tick.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,7 @@ impl Channel {
105105
/// Returns the number of messages in the channel.
106106
#[inline]
107107
pub(crate) fn len(&self) -> usize {
108-
if self.is_empty() {
109-
0
110-
} else {
111-
1
112-
}
108+
usize::from(!self.is_empty())
113109
}
114110

115111
/// Returns the capacity of the channel.

0 commit comments

Comments
 (0)