mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Fix misc clippy warnings
Why does it want me to use bytecount? It's not even faster
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
use std::io::Read;
|
||||
use std::mem::swap;
|
||||
|
||||
use bytecount::naive_count_32;
|
||||
|
||||
use crate::common::read_char_grid;
|
||||
use crate::Solution;
|
||||
|
||||
@@ -9,12 +11,12 @@ fn neighbours(grid: &[Vec<u8>], r: usize, c: usize) -> usize {
|
||||
|
||||
if r > 0 {
|
||||
let range = c.saturating_sub(1)..grid[r - 1].len().min(c + 2);
|
||||
n += grid[r - 1][range].iter().filter(|&&s| s == b'#').count();
|
||||
n += naive_count_32(&grid[r - 1][range], b'#');
|
||||
}
|
||||
|
||||
if r < grid.len() - 1 {
|
||||
let range = c.saturating_sub(1)..grid[r + 1].len().min(c + 2);
|
||||
n += grid[r + 1][range].iter().filter(|&&s| s == b'#').count();
|
||||
n += naive_count_32(&grid[r + 1][range], b'#');
|
||||
}
|
||||
|
||||
if c > 0 && grid[r][c - 1] == b'#' {
|
||||
|
||||
@@ -65,7 +65,7 @@ fn x_mask_permutations(mut x_mask: u64, permutations: &mut Vec<u64>) {
|
||||
while x_mask > 0 {
|
||||
let trailing = x_mask.trailing_zeros();
|
||||
|
||||
let bit = 1 << trailing + offset;
|
||||
let bit = 1 << (trailing + offset);
|
||||
|
||||
x_mask >>= trailing + 1;
|
||||
offset += trailing + 1;
|
||||
|
||||
@@ -15,6 +15,8 @@ fn split_nums<'a>(s: &'a str) -> impl Iterator<Item = u32> + 'a {
|
||||
})
|
||||
}
|
||||
|
||||
// Clippy allow here because this type is used exactly once
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn read_input(input: &mut dyn Read) -> (HashMap<String, Vec<RangeInclusive<u32>>>, Vec<Vec<u32>>) {
|
||||
let mut lines = Lines::new(input).filter(|s| !s.is_empty());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user