From 0382fea400bbf44a278355cb7c1a410696a396fa Mon Sep 17 00:00:00 2001 From: maneatingape <44142177+maneatingape@users.noreply.github.com> Date: Fri, 27 Dec 2024 23:22:10 +0000 Subject: [PATCH] Clippy lints --- src/util/md5.rs | 2 +- src/year2020/day06.rs | 2 +- src/year2022/day03.rs | 2 +- src/year2022/day24.rs | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/md5.rs b/src/util/md5.rs index d1cf6f41..e0013668 100644 --- a/src/util/md5.rs +++ b/src/util/md5.rs @@ -151,7 +151,7 @@ fn common(f: u32, a: u32, b: u32, m: u32, s: u32, k: u32) -> u32 { #[cfg(feature = "simd")] pub mod simd { use std::array; - use std::simd::num::SimdUint; + use std::simd::num::SimdUint as _; use std::simd::{LaneCount, Simd, SupportedLaneCount}; #[inline] diff --git a/src/year2020/day06.rs b/src/year2020/day06.rs index a471026a..39aa1021 100644 --- a/src/year2020/day06.rs +++ b/src/year2020/day06.rs @@ -16,7 +16,7 @@ //! [`count_ones`]: u32::count_ones pub fn parse(input: &str) -> Vec { - input.lines().map(|line| line.bytes().fold(0, |acc, b| acc | 1 << (b - b'a'))).collect() + input.lines().map(|line| line.bytes().fold(0, |acc, b| acc | (1 << (b - b'a')))).collect() } pub fn part1(input: &[u32]) -> u32 { diff --git a/src/year2022/day03.rs b/src/year2022/day03.rs index 26ea9364..d10050da 100644 --- a/src/year2022/day03.rs +++ b/src/year2022/day03.rs @@ -49,7 +49,7 @@ pub fn part2(input: &[&str]) -> u32 { /// Build a set from a slice of ASCII characters, using the `fold` function to repeatedly OR /// bit offsets into an accumulator. fn mask(s: &str) -> u128 { - s.bytes().fold(0, |acc, b| acc | 1 << b) + s.bytes().fold(0, |acc, b| acc | (1 << b)) } /// Find the lowest set bit (there should only be one) then convert to priority using the diff --git a/src/year2022/day24.rs b/src/year2022/day24.rs index 7878b59d..6103a3bb 100644 --- a/src/year2022/day24.rs +++ b/src/year2022/day24.rs @@ -41,8 +41,8 @@ pub fn parse(input: &str) -> Input { let mut horizontal = Vec::with_capacity(width * height); for time in 0..width { for i in 0..height { - let left = left[i] << time | left[i] >> (width - time); - let right = right[i] >> time | right[i] << (width - time); + let left = (left[i] << time) | (left[i] >> (width - time)); + let right = (right[i] >> time) | (right[i] << (width - time)); horizontal.push(left & right); } } @@ -89,7 +89,7 @@ fn expedition(input: &Input, start: usize, forward: bool) -> usize { next = state[i + 1]; // The Elves frontier can spread out 1 in each orthogonal direction unless there // is a blizzard present. - state[i] = (cur | cur >> 1 | cur << 1 | prev | next) + state[i] = (cur | (cur >> 1) | (cur << 1) | prev | next) & horizontal[height * (time % width) + i] & vertical[height * (time % height) + i]; } @@ -106,7 +106,7 @@ fn expedition(input: &Input, start: usize, forward: bool) -> usize { // End position. state[height - 1] |= 1; // If we've reached the start then stop. - if state[0] & 1 << (width - 1) != 0 { + if state[0] & (1 << (width - 1)) != 0 { break time + 1; } }