More Clippy
This commit is contained in:
parent
79cc4ef43c
commit
122e818060
@ -1,12 +1,12 @@
|
|||||||
use std::io::{self, BufRead};
|
use std::io::{self, BufRead};
|
||||||
|
|
||||||
fn increases(measurements: &Vec<u64>) -> u64 {
|
fn increases(measurements: &[u64]) -> u64 {
|
||||||
measurements
|
measurements
|
||||||
.windows(2)
|
.windows(2)
|
||||||
.fold(0, |acc, x| if x[1] > x[0] { acc + 1 } else { acc })
|
.fold(0, |acc, x| if x[1] > x[0] { acc + 1 } else { acc })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convolve(measurements: &Vec<u64>) -> Vec<u64> {
|
fn convolve(measurements: &[u64]) -> Vec<u64> {
|
||||||
measurements.windows(3).map(|x| x.iter().sum()).collect()
|
measurements.windows(3).map(|x| x.iter().sum()).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ impl<const N: usize> Diagnostics<N> {
|
|||||||
u32::from_str_radix(&self.least_common_value(), 2).unwrap()
|
u32::from_str_radix(&self.least_common_value(), 2).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn count_bit(&self, values: &Vec<String>, bit: usize) -> (usize, usize) {
|
fn count_bit(&self, values: &[String], bit: usize) -> (usize, usize) {
|
||||||
values
|
values
|
||||||
.iter()
|
.iter()
|
||||||
.fold((0, 0), |acc, x| match x.chars().nth(bit).unwrap() {
|
.fold((0, 0), |acc, x| match x.chars().nth(bit).unwrap() {
|
||||||
|
@ -11,14 +11,11 @@ struct Board {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Board {
|
impl Board {
|
||||||
fn mark<'a>(&'a mut self, number: u8) {
|
fn mark(&mut self, number: u8) {
|
||||||
for row in self.grid.iter_mut() {
|
for row in self.grid.iter_mut() {
|
||||||
match row.iter_mut().find(|square| square.number == number) {
|
if let Some(square) = row.iter_mut().find(|square| square.number == number) {
|
||||||
Some(square) => {
|
|
||||||
square.marked = true;
|
square.marked = true;
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user