Skip to content

Commit 4f321bf

Browse files
committed
2023: Rust 2024 edition
1 parent 280ef7c commit 4f321bf

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

2023/rust/aoc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "aoc"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

2023/rust/aoc/benches/benchmark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use aoc::day20;
2-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
2+
use criterion::{Criterion, black_box, criterion_group, criterion_main};
33
use std::path::Path;
44

55
pub fn criterion_benchmark(c: &mut Criterion) {

2023/rust/aoc/src/day18/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::Result;
22
use itertools::Itertools;
3-
use std::{fs, isize, path::Path};
3+
use std::{fs, path::Path};
44

55
pub fn part1(input_path: &Path) -> Result<i64> {
66
let input = fs::read_to_string(input_path)?;
@@ -92,7 +92,7 @@ fn get_n_boundary_coordinates(vertices: &[(isize, isize)]) -> isize {
9292
vertices
9393
.iter()
9494
.circular_tuple_windows::<(_, _)>()
95-
.map(|window| (window.1 .0 - window.0 .0).abs() + (window.1 .1 - window.0 .1).abs())
95+
.map(|window| (window.1.0 - window.0.0).abs() + (window.1.1 - window.0.1).abs())
9696
.sum::<isize>()
9797
}
9898

@@ -101,7 +101,7 @@ fn get_n_interior_coordinates(vertices: &[(isize, isize)]) -> isize {
101101
let area = vertices
102102
.iter()
103103
.circular_tuple_windows::<(_, _)>()
104-
.map(|window| window.0 .0 * window.1 .1 - window.1 .0 * window.0 .1)
104+
.map(|window| window.0.0 * window.1.1 - window.1.0 * window.0.1)
105105
.sum::<isize>()
106106
/ 2;
107107

2023/rust/aoc/src/day19/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn parse_input(input: &str) -> (HashMap<String, Workflow>, Vec<Part>) {
6767
.collect();
6868
let else_outcome = s
6969
.clone()
70-
.last()
70+
.next_back()
7171
.unwrap()
7272
.strip_suffix('}')
7373
.unwrap()
@@ -120,9 +120,9 @@ fn is_accepted(workflows: &HashMap<String, Workflow>, workflow: &str, part: &Par
120120
if workflow.else_outcome == "A" {
121121
true
122122
} else if workflow.else_outcome == "R" {
123-
return false;
123+
false
124124
} else {
125-
return is_accepted(workflows, &workflow.else_outcome, part);
125+
is_accepted(workflows, &workflow.else_outcome, part)
126126
}
127127
}
128128

@@ -165,9 +165,9 @@ fn find_accepted_hypercubes(
165165
if workflow.else_outcome == "A" {
166166
vec![hypercube.clone()]
167167
} else if workflow.else_outcome == "R" {
168-
return vec![];
168+
vec![]
169169
} else {
170-
return find_accepted_hypercubes(workflows, &workflow.else_outcome, hypercube);
170+
find_accepted_hypercubes(workflows, &workflow.else_outcome, hypercube)
171171
}
172172
}
173173

2023/rust/aoc/src/day22/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Result;
22
use itertools::Itertools;
33
use slotmap::{DefaultKey, SecondaryMap, SlotMap};
4-
use std::{cmp::Ordering, collections::HashSet, fs, path::Path, usize};
4+
use std::{cmp::Ordering, collections::HashSet, fs, path::Path};
55

66
pub fn part1(input_path: &Path) -> Result<i64> {
77
let input = fs::read_to_string(input_path)?;

0 commit comments

Comments
 (0)