mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 08:30:45 +00:00
20 lines
459 B
Rust
20 lines
459 B
Rust
#![warn(clippy::manual_is_power_of_two)]
|
|
|
|
fn main() {
|
|
let a = 16_u64;
|
|
|
|
let _ = a.is_power_of_two();
|
|
let _ = a.is_power_of_two();
|
|
|
|
// Test different orders of expression
|
|
let _ = a.is_power_of_two();
|
|
let _ = a.is_power_of_two();
|
|
let _ = a.is_power_of_two();
|
|
let _ = a.is_power_of_two();
|
|
|
|
let b = 4_i64;
|
|
|
|
// is_power_of_two only works for unsigned integers
|
|
let _ = b.count_ones() == 1;
|
|
let _ = b & (b - 1) == 0;
|
|
}
|