]> aoc.elinar.fr Git - aoc_2024/commitdiff
Petite amélioration de la maquette
authoralex <>
Fri, 6 Dec 2024 11:59:24 +0000 (12:59 +0100)
committeralex <>
Fri, 6 Dec 2024 11:59:24 +0000 (12:59 +0100)
Makefile
src/day00.rs [deleted file]
src/template.rs [new file with mode: 0644]

index 09b3f87325b98d9d67c6b67c5be0eecd11ade64d..6e6505d6a893301b7b3cfa98cf2d1a074c4d3336 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 # - update the main to integrate the new day
 new-day%:
        if [ -f "src/$(subst new-,,$@).rs" ]; then return 1; fi
-       cp -v src/day00.rs src/$(subst new-,,$@).rs
+       cp -v src/template.rs src/$(subst new-,,$@).rs
        sed -i \
                -e "$$(( $$(grep -n main src/main.rs | cut -d ':' -f 1) - 2 ))a\pub mod $(subst new-,,$@);" \
                -e "/_ =>/i\        \"$(subst new-,,$@)\" => $(subst new-,,$@)::run(\&input)?," \
diff --git a/src/day00.rs b/src/day00.rs
deleted file mode 100644 (file)
index f1a9a82..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-use std::error::Error;
-use std::path::Path;
-
-pub fn run(input: &str) -> Result<(), Box<dyn Error>> {
-    let res = run_part1(&input)?;
-    println!("{res}");
-
-    let res = run_part2(&input)?;
-    println!("{res}");
-
-    Ok(())
-}
-
-fn get_day() -> String {
-    let filename = file!();
-    Path::new(filename).file_stem().unwrap().to_str().unwrap().to_string()
-}
-
-fn run_part1(input: &str) -> Result<u32, Box<dyn Error>> {
-    println!("Running {} - part 1", get_day());
-
-    Ok(0)
-}
-
-fn run_part2(input: &str) -> Result<u32, Box<dyn Error>> {
-    println!("Running {} - part 2", get_day());
-
-    Ok(0)
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    static TEXT_INPUT: &str = "\
-";
-
-    #[test]
-    fn test_part1() {
-        assert_eq!(0, run_part1(TEXT_INPUT).unwrap());
-    }
-
-    #[test]
-    fn test_part2() {
-        assert_eq!(0, run_part2(TEXT_INPUT).unwrap());
-    }
-}
diff --git a/src/template.rs b/src/template.rs
new file mode 100644 (file)
index 0000000..9bf5f24
--- /dev/null
@@ -0,0 +1,47 @@
+use std::error::Error;
+use std::path::Path;
+
+fn run_part1(input: &str) -> Result<u32, Box<dyn Error>> {
+    println!("Running {} - part 1", get_day());
+
+    Ok(0)
+}
+
+fn run_part2(input: &str) -> Result<u32, Box<dyn Error>> {
+    println!("Running {} - part 2", get_day());
+
+    Ok(0)
+}
+
+pub fn run(input: &str) -> Result<(), Box<dyn Error>> {
+    let res = run_part1(&input)?;
+    println!("{res}");
+
+    let res = run_part2(&input)?;
+    println!("{res}");
+
+    Ok(())
+}
+
+fn get_day() -> String {
+    let filename = file!();
+    Path::new(filename).file_stem().unwrap().to_str().unwrap().to_string()
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    static TEXT_INPUT: &str = "\
+";
+
+    #[test]
+    fn test_part1() {
+        assert_eq!(0, run_part1(TEXT_INPUT).unwrap());
+    }
+
+    #[test]
+    fn test_part2() {
+        assert_eq!(0, run_part2(TEXT_INPUT).unwrap());
+    }
+}