Skip to content

Commit b630cf3

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

File tree

15 files changed

+35
-35
lines changed

15 files changed

+35
-35
lines changed

2017/day1/day1.rs

Lines changed: 2 additions & 2 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
}

2017/day10/day10.rs

Lines changed: 3 additions & 3 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
data: String::new(),
1313
}
1414
}
@@ -17,7 +17,7 @@ impl Puzzle {
1717
fn configure(&mut self, path: &str) {
1818
let data = std::fs::read_to_string(path).unwrap();
1919

20-
self.data = data.trim().to_owned();
20+
data.trim().clone_into(&mut self.data);
2121
}
2222

2323
/// Solve part one.

2017/day11/day11.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const STEP_X: i32 = 1;
1010
const STEP_Y: i32 = 1;
1111

1212
impl Puzzle {
13-
fn new() -> Puzzle {
14-
Puzzle {
13+
const fn new() -> Self {
14+
Self {
1515
data: String::new(),
1616
part1: 0,
1717
part2: 0,
@@ -26,7 +26,7 @@ impl Puzzle {
2626
}
2727

2828
/// Determine the fewest number of steps to return to (0,0).
29-
fn steps(x: i32, y: i32) -> u32 {
29+
const fn steps(x: i32, y: i32) -> u32 {
3030
let mut x = x.abs();
3131
let mut y = y.abs();
3232
let mut steps = 0;

2017/day13/day13.rs

Lines changed: 2 additions & 2 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+
fn new() -> Self {
11+
Self {
1212
heights: HashMap::new(),
1313
}
1414
}

2017/day14/day14.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use aoc::grid::Grid;
44
use aoc::knot;
55

6-
fn count_ones(value: u8) -> u32 {
6+
const fn count_ones(value: u8) -> u32 {
77
let mut count = 0;
88
let mut value = value;
99

@@ -20,8 +20,8 @@ struct Puzzle {
2020
}
2121

2222
impl Puzzle {
23-
fn new() -> Puzzle {
24-
Puzzle { key: String::new() }
23+
const fn new() -> Self {
24+
Self { key: String::new() }
2525
}
2626

2727
/// Get the puzzle input.

2017/day15/day15.rs

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

88
impl Puzzle {
9-
fn new() -> Puzzle {
10-
Puzzle { a: 0, b: 0 }
9+
const fn new() -> Self {
10+
Self { a: 0, b: 0 }
1111
}
1212

1313
/// Get the puzzle input.

2017/day16/day16.rs

Lines changed: 2 additions & 2 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 { program: vec![] }
8+
const fn new() -> Self {
9+
Self { program: vec![] }
1010
}
1111

1212
/// Get the puzzle input.

2017/day17/day17.rs

Lines changed: 2 additions & 2 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 { step: 0 }
8+
const fn new() -> Self {
9+
Self { step: 0 }
1010
}
1111

1212
/// Get the puzzle input.

2017/day18/day18.rs

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

107107
impl Puzzle {
108-
fn new() -> Puzzle {
109-
Puzzle { program: vec![] }
108+
const fn new() -> Self {
109+
Self { program: vec![] }
110110
}
111111

112112
/// Get the puzzle input.

2017/day2/day2.rs

Lines changed: 2 additions & 2 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 { data: vec![] }
8+
const fn new() -> Self {
9+
Self { data: vec![] }
1010
}
1111

1212
/// Get the puzzle input.

0 commit comments

Comments
 (0)