Skip to content

Commit b2ae635

Browse files
committed
clippy nursery 🍼 (almost)
1 parent b630cf3 commit b2ae635

File tree

25 files changed

+202
-207
lines changed

25 files changed

+202
-207
lines changed

2023/day1/day1.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ struct Puzzle {
55
}
66

77
impl Puzzle {
8-
fn new() -> Puzzle {
9-
Puzzle {
8+
const fn new() -> Self {
9+
Self {
1010
data: String::new(),
1111
}
1212
}
@@ -83,6 +83,14 @@ impl Puzzle {
8383
}
8484
}
8585

86+
fn main() {
87+
let args = aoc::parse_args();
88+
let mut puzzle = Puzzle::new();
89+
puzzle.configure(args.path.as_str());
90+
println!("{}", puzzle.part1());
91+
println!("{}", puzzle.part2());
92+
}
93+
8694
/// Test from puzzle input
8795
#[cfg(test)]
8896
mod test {
@@ -102,11 +110,3 @@ mod test {
102110
assert_eq!(puzzle.part2(), 281);
103111
}
104112
}
105-
106-
fn main() {
107-
let args = aoc::parse_args();
108-
let mut puzzle = Puzzle::new();
109-
puzzle.configure(args.path.as_str());
110-
println!("{}", puzzle.part1());
111-
println!("{}", puzzle.part2());
112-
}

2023/day10/day10.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ struct Puzzle {
1717
}
1818

1919
impl Puzzle {
20-
fn new() -> Puzzle {
21-
Puzzle {
20+
const fn new() -> Self {
21+
Self {
2222
_grid: vec![],
2323
sx: 0,
2424
sy: 0,
@@ -113,7 +113,7 @@ impl Puzzle {
113113
.map(|&(x, y)| Coord { x, y })
114114
.collect::<LineString<i32>>();
115115

116-
let polygon = Polygon::new(line_string.clone(), vec![]);
116+
let polygon = Polygon::new(line_string, vec![]);
117117

118118
let mut n = 0;
119119
for (x, y) in iproduct!(0..self.sx, 0..self.sy) {
@@ -127,6 +127,14 @@ impl Puzzle {
127127
}
128128
}
129129

130+
fn main() {
131+
let args = aoc::parse_args();
132+
let mut puzzle = Puzzle::new();
133+
puzzle.configure(args.path.as_str());
134+
println!("{}", puzzle.part1());
135+
println!("{}", puzzle.part2());
136+
}
137+
130138
/// Test from puzzle input
131139
#[cfg(test)]
132140
mod test {
@@ -172,11 +180,3 @@ mod test {
172180
assert_eq!(puzzle.part2(), 10);
173181
}
174182
}
175-
176-
fn main() {
177-
let args = aoc::parse_args();
178-
let mut puzzle = Puzzle::new();
179-
puzzle.configure(args.path.as_str());
180-
println!("{}", puzzle.part1());
181-
println!("{}", puzzle.part2());
182-
}

2023/day11/day11.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ struct Puzzle {
77
}
88

99
impl Puzzle {
10-
fn new() -> Puzzle {
11-
Puzzle {
10+
const fn new() -> Self {
11+
Self {
1212
empty_rows: vec![],
1313
empty_cols: vec![],
1414
galaxies: vec![],
@@ -84,6 +84,14 @@ impl Puzzle {
8484
}
8585
}
8686

87+
fn main() {
88+
let args = aoc::parse_args();
89+
let mut puzzle = Puzzle::new();
90+
puzzle.configure(args.path.as_str());
91+
println!("{}", puzzle.part1());
92+
println!("{}", puzzle.part2());
93+
}
94+
8795
/// Test from puzzle input
8896
#[cfg(test)]
8997
mod test {
@@ -104,11 +112,3 @@ mod test {
104112
assert_eq!(puzzle.solve(100), 8410);
105113
}
106114
}
107-
108-
fn main() {
109-
let args = aoc::parse_args();
110-
let mut puzzle = Puzzle::new();
111-
puzzle.configure(args.path.as_str());
112-
println!("{}", puzzle.part1());
113-
println!("{}", puzzle.part2());
114-
}

2023/day12/day12.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ struct Puzzle {
6666
}
6767

6868
impl Puzzle {
69-
fn new() -> Puzzle {
70-
Puzzle { field: vec![] }
69+
const fn new() -> Self {
70+
Self { field: vec![] }
7171
}
7272

7373
/// Get the puzzle input.
@@ -113,6 +113,14 @@ impl Puzzle {
113113
}
114114
}
115115

116+
fn main() {
117+
let args = aoc::parse_args();
118+
let mut puzzle = Puzzle::new();
119+
puzzle.configure(args.path.as_str());
120+
println!("{}", puzzle.part1());
121+
println!("{}", puzzle.part2());
122+
}
123+
116124
/// Test from puzzle input
117125
#[cfg(test)]
118126
mod test {
@@ -132,11 +140,3 @@ mod test {
132140
assert_eq!(puzzle.part2(), 525152);
133141
}
134142
}
135-
136-
fn main() {
137-
let args = aoc::parse_args();
138-
let mut puzzle = Puzzle::new();
139-
puzzle.configure(args.path.as_str());
140-
println!("{}", puzzle.part1());
141-
println!("{}", puzzle.part2());
142-
}

2023/day13/day13.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ struct Puzzle {
8181
}
8282

8383
impl Puzzle {
84-
fn new() -> Puzzle {
85-
Puzzle { patterns: vec![] }
84+
const fn new() -> Self {
85+
Self { patterns: vec![] }
8686
}
8787

8888
/// Get the puzzle input.
@@ -113,6 +113,14 @@ impl Puzzle {
113113
}
114114
}
115115

116+
fn main() {
117+
let args = aoc::parse_args();
118+
let mut puzzle = Puzzle::new();
119+
puzzle.configure(args.path.as_str());
120+
println!("{}", puzzle.part1());
121+
println!("{}", puzzle.part2());
122+
}
123+
116124
/// Test from puzzle input
117125
#[cfg(test)]
118126
mod test {
@@ -132,11 +140,3 @@ mod test {
132140
assert_eq!(puzzle.part2(), 400);
133141
}
134142
}
135-
136-
fn main() {
137-
let args = aoc::parse_args();
138-
let mut puzzle = Puzzle::new();
139-
puzzle.configure(args.path.as_str());
140-
println!("{}", puzzle.part1());
141-
println!("{}", puzzle.part2());
142-
}

2023/day14/day14.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ struct Puzzle {
165165
}
166166

167167
impl Puzzle {
168-
fn new() -> Puzzle {
169-
Puzzle {
168+
const fn new() -> Self {
169+
Self {
170170
data: String::new(),
171171
}
172172
}
@@ -265,6 +265,19 @@ impl Puzzle {
265265
}
266266
}
267267

268+
fn main() {
269+
let args = aoc::parse_args();
270+
let mut puzzle = Puzzle::new();
271+
puzzle.configure(args.path.as_str());
272+
273+
if args.verbose {
274+
puzzle.anim();
275+
} else {
276+
println!("{}", puzzle.part1());
277+
println!("{}", puzzle.part2());
278+
}
279+
}
280+
268281
/// Test from puzzle input
269282
#[cfg(test)]
270283
mod test {
@@ -284,16 +297,3 @@ mod test {
284297
assert_eq!(puzzle.part2(), 64);
285298
}
286299
}
287-
288-
fn main() {
289-
let args = aoc::parse_args();
290-
let mut puzzle = Puzzle::new();
291-
puzzle.configure(args.path.as_str());
292-
293-
if args.verbose {
294-
puzzle.anim();
295-
} else {
296-
println!("{}", puzzle.part1());
297-
println!("{}", puzzle.part2());
298-
}
299-
}

2023/day15/day15.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ struct Puzzle {
1010
}
1111

1212
impl Puzzle {
13-
fn new() -> Puzzle {
14-
Puzzle {
13+
const fn new() -> Self {
14+
Self {
1515
data: String::new(),
1616
}
1717
}

2023/day16/day16.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ struct Puzzle {
88
}
99

1010
impl Puzzle {
11-
fn new() -> Puzzle {
12-
Puzzle {
11+
const fn new() -> Self {
12+
Self {
1313
mirrors: vec![],
1414
beams: vec![],
1515
sx: 0,

2023/day17/day17.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ enum Direction {
1515
impl Direction {
1616
/// Move one step in the given direction, if possible.
1717
fn step(self, x: usize, y: usize, sx: usize, sy: usize) -> Option<(usize, usize)> {
18-
if self == Direction::North && y > 0 {
18+
if self == Self::North && y > 0 {
1919
Some((x, y - 1))
20-
} else if self == Direction::East && x < sx - 1 {
20+
} else if self == Self::East && x < sx - 1 {
2121
Some((x + 1, y))
22-
} else if self == Direction::South && y < sy - 1 {
22+
} else if self == Self::South && y < sy - 1 {
2323
Some((x, y + 1))
24-
} else if self == Direction::West && x > 0 {
24+
} else if self == Self::West && x > 0 {
2525
Some((x - 1, y))
2626
} else {
2727
None
2828
}
2929
}
3030

3131
/// Indicate if two directions are opposite.
32-
fn is_opposite(self, other: Direction) -> bool {
33-
self == Direction::North && other == Direction::South
34-
|| self == Direction::South && other == Direction::North
35-
|| self == Direction::East && other == Direction::West
36-
|| self == Direction::West && other == Direction::East
32+
fn is_opposite(self, other: Self) -> bool {
33+
self == Self::North && other == Self::South
34+
|| self == Self::South && other == Self::North
35+
|| self == Self::East && other == Self::West
36+
|| self == Self::West && other == Self::East
3737
}
3838
}
3939

@@ -72,8 +72,8 @@ struct Puzzle {
7272
}
7373

7474
impl Puzzle {
75-
fn new() -> Puzzle {
76-
Puzzle {
75+
const fn new() -> Self {
76+
Self {
7777
grid: vec![],
7878
sx: 0,
7979
sy: 0,
@@ -188,6 +188,14 @@ impl Puzzle {
188188
}
189189
}
190190

191+
fn main() {
192+
let args = aoc::parse_args();
193+
let mut puzzle = Puzzle::new();
194+
puzzle.configure(args.path.as_str());
195+
println!("{}", puzzle.part1());
196+
println!("{}", puzzle.part2());
197+
}
198+
191199
/// Test from puzzle input
192200
#[cfg(test)]
193201
mod test {
@@ -214,11 +222,3 @@ mod test {
214222
assert_eq!(puzzle.part2(), 71);
215223
}
216224
}
217-
218-
fn main() {
219-
let args = aoc::parse_args();
220-
let mut puzzle = Puzzle::new();
221-
puzzle.configure(args.path.as_str());
222-
println!("{}", puzzle.part1());
223-
println!("{}", puzzle.part2());
224-
}

2023/day18/day18.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ struct Puzzle {
1919
}
2020

2121
impl Puzzle {
22-
fn new() -> Puzzle {
23-
Puzzle {
22+
const fn new() -> Self {
23+
Self {
2424
data: String::new(),
2525
}
2626
}
@@ -93,6 +93,14 @@ impl Puzzle {
9393
}
9494
}
9595

96+
fn main() {
97+
let args = aoc::parse_args();
98+
let mut puzzle = Puzzle::new();
99+
puzzle.configure(args.path.as_str());
100+
println!("{}", puzzle.part1());
101+
println!("{}", puzzle.part2());
102+
}
103+
96104
/// Test from puzzle input
97105
#[cfg(test)]
98106
mod test {
@@ -112,11 +120,3 @@ mod test {
112120
assert_eq!(puzzle.part2(), 952408144115);
113121
}
114122
}
115-
116-
fn main() {
117-
let args = aoc::parse_args();
118-
let mut puzzle = Puzzle::new();
119-
puzzle.configure(args.path.as_str());
120-
println!("{}", puzzle.part1());
121-
println!("{}", puzzle.part2());
122-
}

0 commit comments

Comments
 (0)