all: fix clippy lints for rust 1.65
This commit is contained in:
parent
1d9433098d
commit
008fb72a98
11 changed files with 21 additions and 39 deletions
|
|
@ -30,13 +30,7 @@ fn compute_gamma(binary_numbers: &[&str], size: usize) -> u64 {
|
|||
let mut gamma = 0;
|
||||
|
||||
for pos in 0..size {
|
||||
let digit = if count_ones(binary_numbers, pos) > (binary_numbers.len() / 2) {
|
||||
// majority of ones
|
||||
1
|
||||
} else {
|
||||
// majority of zeroes
|
||||
0
|
||||
};
|
||||
let digit = u64::from(count_ones(binary_numbers, pos) > (binary_numbers.len() / 2));
|
||||
gamma = (gamma << 1) | digit;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ impl Grid {
|
|||
fn unmarked_numbers(&self) -> impl Iterator<Item = u8> + '_ {
|
||||
self.number_to_pos
|
||||
.iter()
|
||||
.filter_map(|(num, &(x, y))| (!self.access_grid(x, y)).then(|| *num))
|
||||
.filter_map(|(num, &(x, y))| (!self.access_grid(x, y)).then_some(*num))
|
||||
}
|
||||
|
||||
fn access_grid(&self, x: usize, y: usize) -> bool {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ impl std::str::FromStr for Rules {
|
|||
let (pair, res) = l.split_once(" -> ").context("couldn't parse rule")?;
|
||||
Ok((
|
||||
(
|
||||
*pair.as_bytes().get(0).context("couldn't parse rule")?,
|
||||
*pair.as_bytes().first().context("couldn't parse rule")?,
|
||||
*pair.as_bytes().get(1).context("couldn't parse rule")?,
|
||||
),
|
||||
res.bytes().next().context("couldn't parse rule")?,
|
||||
|
|
|
|||
|
|
@ -64,31 +64,19 @@ impl Packet {
|
|||
debug_assert_eq!(op.sub_packets.len(), 2);
|
||||
let pack1 = &op.sub_packets[0];
|
||||
let pack2 = &op.sub_packets[1];
|
||||
if pack1.value() > pack2.value() {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
u64::from(pack1.value() > pack2.value())
|
||||
}
|
||||
OperatorType::LessThan => {
|
||||
debug_assert_eq!(op.sub_packets.len(), 2);
|
||||
let pack1 = &op.sub_packets[0];
|
||||
let pack2 = &op.sub_packets[1];
|
||||
if pack1.value() < pack2.value() {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
u64::from(pack1.value() < pack2.value())
|
||||
}
|
||||
OperatorType::EqualTo => {
|
||||
debug_assert_eq!(op.sub_packets.len(), 2);
|
||||
let pack1 = &op.sub_packets[0];
|
||||
let pack2 = &op.sub_packets[1];
|
||||
if pack1.value() == pack2.value() {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
u64::from(pack1.value() == pack2.value())
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue