瀏覽代碼

day01 clippy and cleanup

wullewutz 2 年之前
父節點
當前提交
03f119f4e5
共有 1 個文件被更改,包括 10 次插入12 次删除
  1. 10 12
      day_01/src/main.rs

+ 10 - 12
day_01/src/main.rs

@@ -1,5 +1,3 @@
-#[allow(dead_code)]
-
 fn first_part(input: &str) -> usize {
     let mut sum = 0;
     for line in input.lines() {
@@ -15,7 +13,7 @@ fn first_part(input: &str) -> usize {
 fn second_part(input: &str) -> usize {
     let mut sum = 0;
     for line in input.lines() {
-        let (first, last) = find_first_last(&line);
+        let (first, last) = find_first_last(line);
         let lineval = first * 10 + last;
         sum += lineval;
     }
@@ -70,21 +68,21 @@ mod day1_examples {
     #[test]
     fn example_1st_part() {
         let example = "1abc2
-            pqr3stu8vwx
-            a1b2c3d4e5f
-            treb7uchet";
+pqr3stu8vwx
+a1b2c3d4e5f
+treb7uchet";
         assert_eq!(crate::first_part(example), 142);
     }
 
     #[test]
     fn example_2nd_part() {
         let example = "two1nine
-            eightwothree
-            abcone2threexyz
-            xtwone3four
-            4nineeightseven2
-            zoneight234
-            7pqrstsixteen";
+eightwothree
+abcone2threexyz
+xtwone3four
+4nineeightseven2
+zoneight234
+7pqrstsixteen";
         assert_eq!(crate::second_part(example), 281);
     }
 }