File tree Expand file tree Collapse file tree 15 files changed +35
-35
lines changed
Expand file tree Collapse file tree 15 files changed +35
-35
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ struct Puzzle {
55}
66
77impl Puzzle {
8- fn new ( ) -> Puzzle {
9- Puzzle {
8+ const fn new ( ) -> Self {
9+ Self {
1010 data : String :: new ( ) ,
1111 }
1212 }
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ struct Puzzle {
77}
88
99impl 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.
Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ const STEP_X: i32 = 1;
1010const STEP_Y : i32 = 1 ;
1111
1212impl 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 ;
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ struct Puzzle {
77}
88
99impl Puzzle {
10- fn new ( ) -> Puzzle {
11- Puzzle {
10+ fn new ( ) -> Self {
11+ Self {
1212 heights : HashMap :: new ( ) ,
1313 }
1414 }
Original file line number Diff line number Diff line change 33use aoc:: grid:: Grid ;
44use 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
2222impl 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.
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ struct Puzzle {
66}
77
88impl 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.
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ struct Puzzle {
55}
66
77impl 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.
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ struct Puzzle {
55}
66
77impl 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.
Original file line number Diff line number Diff line change @@ -105,8 +105,8 @@ struct Puzzle {
105105}
106106
107107impl 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.
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ struct Puzzle {
55}
66
77impl 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.
You can’t perform that action at this time.
0 commit comments