Skip to content

Commit e9f379e

Browse files
committed
code cleanup
1 parent 80775db commit e9f379e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/bin/06.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn parse_data(input: &str) -> DataType {
3434
let mut obstructions = FastSet::new();
3535

3636
let height = input.lines().count();
37-
let width = input.split_once("\n").unwrap().0.len();
37+
let width = input.lines().next().unwrap().len();
3838

3939
for (y, line) in input.lines().enumerate() {
4040
for (x, v) in line.bytes().enumerate() {

src/bin/08.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,22 @@ impl MapSize {
2525
}
2626

2727
fn parse_data(input: &str) -> DataType {
28-
let mut data = FastMap::new();
28+
let mut data: FastMap<u8, Vec<Point>> = FastMap::new();
2929

3030
let width = input.lines().next().unwrap().len() as i32;
3131
let height = input.lines().count() as i32;
3232

3333
for (y, line) in input.lines().enumerate() {
3434
for (x, c) in line.bytes().enumerate() {
3535
if c != b'.' {
36-
(*data.entry(c).or_insert(vec![])).push(Point::new(x as i32, y as i32));
36+
let p = Point::new(x as i32, y as i32);
37+
data.entry(c).or_default().push(p);
3738
}
3839
}
3940
}
4041

4142
DataType {
42-
data: data,
43+
data,
4344
map_size: MapSize {
4445
min_x: 0,
4546
max_x: width - 1,

0 commit comments

Comments
 (0)