Skip to content

Commit 86268a8

Browse files
committed
Tidy code
1 parent d604727 commit 86268a8

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/year2015/day19.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn part1(input: &Input<'_>) -> usize {
2828
// Group replacements of the same size together.
2929
for &(from, to) in replacements {
3030
let extra = to.len() - from.len();
31-
groups.entry(extra).or_insert(Vec::new()).push((from, to));
31+
groups.entry(extra).or_insert_with(Vec::new).push((from, to));
3232
}
3333

3434
for (_, group) in groups {

src/year2023/day17.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn astar<const L: i32, const U: i32>(grid: &Grid<i32>) -> i32 {
5656
let heat = &grid.bytes;
5757

5858
let mut index = 0;
59-
let mut todo = repeat_with(|| Vec::with_capacity(1000)).take(100).collect::<Vec<_>>();
59+
let mut todo: Vec<_> = repeat_with(|| Vec::with_capacity(1000)).take(100).collect();
6060
let mut cost = vec![[i32::MAX; 2]; heat.len()];
6161

6262
// Start from the top left corner checking both vertical and horizontal directions.

src/year2023/day23.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ fn compress(input: &str) -> Graph {
327327
}
328328

329329
// Graph is undirected so add both edges.
330-
edges.entry(from).or_insert(Vec::new()).push(to);
331-
edges.entry(to).or_insert(Vec::new()).push(from);
330+
edges.entry(from).or_insert_with(Vec::new).push(to);
331+
edges.entry(to).or_insert_with(Vec::new).push(from);
332332
weight.insert((from, to), cost);
333333
weight.insert((to, from), cost);
334334

0 commit comments

Comments
 (0)