Skip to content

Commit b279037

Browse files
committed
Update to rust 1.91.1
1 parent c56b678 commit b279037

File tree

21 files changed

+37
-48
lines changed

21 files changed

+37
-48
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2024"
99
homepage = "https://github.com/fornwall/advent-of-code"
1010
license = "MIT"
1111
repository = "https://github.com/fornwall/advent-of-code"
12-
rust-version = "1.89.0"
12+
rust-version = "1.91.1"
1313
version = "2024.21.0"
1414

1515
[profile.release]

crates/core/src/common/character_recognition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fn recognize_letter(
179179
}
180180

181181
pub fn recognize(bytes: &[bool]) -> Result<String, String> {
182-
if bytes.len() % (CHAR_WIDTH * CHAR_HEIGHT) != 0 {
182+
if !bytes.len().is_multiple_of(CHAR_WIDTH * CHAR_HEIGHT) {
183183
return Err(format!(
184184
"Input length is not a multiple of {}",
185185
CHAR_WIDTH * CHAR_HEIGHT

crates/core/src/year2015/day23.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Computer {
8787
instruction_pointer += offset;
8888
}
8989
Some(&Instruction::JumpIfEven(register, offset)) => {
90-
instruction_pointer += if self.registers[register as usize] % 2 == 0 {
90+
instruction_pointer += if self.registers[register as usize].is_multiple_of(2) {
9191
offset
9292
} else {
9393
1

crates/core/src/year2018/day15.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl Board {
127127
fn perform_round(&mut self) {
128128
self.round += 1;
129129
self.full_round = true;
130-
let even_round = self.round % 2 == 0;
130+
let even_round = self.round.is_multiple_of(2);
131131

132132
for y in 0..self.height {
133133
for x in 0..self.width {

crates/core/src/year2019/day08.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const PIXELS_WIDE: usize = NUM_LETTERS * CHAR_WIDTH;
66
const LAYER_SIZE: usize = PIXELS_WIDE * CHAR_HEIGHT;
77

88
pub fn solve(input: &Input) -> Result<String, String> {
9-
if input.text.len() % LAYER_SIZE != 0 {
9+
if !input.text.len().is_multiple_of(LAYER_SIZE) {
1010
return Err(format!(
1111
"Invalid input - expected to be multiple of layer size ({LAYER_SIZE})"
1212
));

crates/core/src/year2019/day17.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,18 @@ pub fn solve(input: &Input) -> Result<String, String> {
121121

122122
let mut robot_direction = Direction::Up;
123123
let mut robot_position: (i32, i32) = (0, 0);
124-
for y in 0..map.len() {
125-
for x in 0..map[0].len() {
126-
if map[y][x] == b'^' {
124+
for (y, row) in map.iter().enumerate() {
125+
for (x, &tile) in row.iter().enumerate() {
126+
if tile == b'^' {
127127
robot_direction = Direction::Up;
128128
robot_position = (x as i32, y as i32);
129-
} else if map[y][x] == b'v' {
129+
} else if tile == b'v' {
130130
robot_direction = Direction::Down;
131131
robot_position = (x as i32, y as i32);
132-
} else if map[y][x] == b'<' {
132+
} else if tile == b'<' {
133133
robot_direction = Direction::Left;
134134
robot_position = (x as i32, y as i32);
135-
} else if map[y][x] == b'>' {
135+
} else if tile == b'>' {
136136
robot_direction = Direction::Right;
137137
robot_position = (x as i32, y as i32);
138138
}

crates/core/src/year2020/day20.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ impl Tile {
147147
&& current.edges[2].matching.is_none() == (y + 1 == composed_image_width)
148148
&& current.edges[3].matching.is_none() == (x == 0)
149149
{
150+
#[allow(clippy::useless_let_if_seq)]
150151
let mut possible = true;
151152
if x != 0
152153
&& let Some(tile_to_left) = composed_image.get(&(x - 1, y))

crates/core/src/year2022/day17.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn solve(input: &Input) -> Result<u64, String> {
5757
(current_rock_count - last_seen_rock_drop_iteration) as u64;
5858
let remaining_rocks = target_rocks_count - current_rock_count as u64;
5959

60-
if remaining_rocks % rocks_per_cycle == 0 {
60+
if remaining_rocks.is_multiple_of(rocks_per_cycle) {
6161
let remaining_cycles = remaining_rocks / rocks_per_cycle;
6262
let highest_rock_growth = grid.highest_rock - last_seen_highest_rock;
6363
return Ok(grid.highest_rock as u64

crates/core/src/year2022/day19.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ fn most_geodes_opened(blueprint: &Blueprint, minutes: u32) -> u32 {
117117
}
118118

119119
let mut new_state = state;
120-
for j in 0..4 {
121-
new_state.ores[j] = new_state.ores[j]
122-
+ state.robots[j] * (minutes_before_resources_obtained + 1)
120+
for (j, ore) in new_state.ores.iter_mut().enumerate() {
121+
*ore = *ore + state.robots[j] * (minutes_before_resources_obtained + 1)
123122
- blueprint[robot_to_build_idx][j];
124123
}
125124
new_state.minutes_remaining -= minutes_before_resources_obtained + 1;

crates/core/src/year2022/day22.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ impl Cube {
229229

230230
fn step_forward(&mut self, steps: u8, mut direction: Direction) -> Direction {
231231
#![allow(clippy::panic)]
232+
#![allow(clippy::useless_let_if_seq)]
232233
let mut delta = direction.delta();
233234
for _step in 0..steps {
234235
let mut new_position = (

0 commit comments

Comments
 (0)