From 6be67b375d1f584373a708d8f2f48db9e9fb9bed Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 16 Dec 2022 21:08:10 +0900 Subject: [PATCH] Fix clippy::bool_to_int_with_if warning ``` warning: boolean to int conversion using if --> src/single.rs:93:9 | 93 | / if self.state.load(Ordering::SeqCst) & PUSHED == 0 { 94 | | 0 95 | | } else { 96 | | 1 97 | | } | |_________^ help: replace with from: `usize::from(self.state.load(Ordering::SeqCst) & PUSHED != 0)` | = note: `(self.state.load(Ordering::SeqCst) & PUSHED != 0) as usize` or `(self.state.load(Ordering::SeqCst) & PUSHED != 0).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 ``` --- src/single.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/single.rs b/src/single.rs index c7748b3..0efa0b7 100644 --- a/src/single.rs +++ b/src/single.rs @@ -90,11 +90,7 @@ impl Single { /// Returns the number of items in the queue. pub fn len(&self) -> usize { - if self.state.load(Ordering::SeqCst) & PUSHED == 0 { - 0 - } else { - 1 - } + usize::from(self.state.load(Ordering::SeqCst) & PUSHED != 0) } /// Returns `true` if the queue is empty.