From e8a9524f26e97c27a9530aba12025fa8a8ee846c Mon Sep 17 00:00:00 2001 From: mirsella Date: Mon, 11 Dec 2023 11:21:32 +0100 Subject: [PATCH] template: build.rs dont write file if no change made --- 2023/day12/.gitignore | 19 ------------------- 2023/day12/Cargo.toml | 10 ---------- 2023/day12/build.rs | 28 ---------------------------- 2023/day12/src/main.rs | 24 ------------------------ 4 files changed, 81 deletions(-) delete mode 100644 2023/day12/.gitignore delete mode 100644 2023/day12/Cargo.toml delete mode 100644 2023/day12/build.rs delete mode 100644 2023/day12/src/main.rs diff --git a/2023/day12/.gitignore b/2023/day12/.gitignore deleted file mode 100644 index e983cca..0000000 --- a/2023/day12/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -input.txt -flamegraph.svg -perf.data* -### Rust -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - -# These are backup files generated by rustfmt -**/*.rs.bk - -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb - diff --git a/2023/day12/Cargo.toml b/2023/day12/Cargo.toml deleted file mode 100644 index a172d25..0000000 --- a/2023/day12/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "day12" -authors = ["mirsella "] -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] - diff --git a/2023/day12/build.rs b/2023/day12/build.rs deleted file mode 100644 index b6a19a0..0000000 --- a/2023/day12/build.rs +++ /dev/null @@ -1,28 +0,0 @@ -use std::fs::File; -use std::io::{self, Read}; -use std::path::PathBuf; -use std::{env, fs}; - -fn replace_in_file(file_path: &PathBuf, old: &str, new: &str) -> io::Result<()> { - let mut contents = String::new(); - File::open(file_path)?.read_to_string(&mut contents)?; - let new_contents = contents.replace(old, new); - if contents != new_contents { - println!("Updating {}", file_path.display()); - fs::write(file_path, new_contents)?; - } - Ok(()) -} - -fn main() -> io::Result<()> { - let pkg_name = env::var("CARGO_PKG_NAME").unwrap(); - replace_in_file( - &"../Cargo.toml".into(), - &format!("# \"{pkg_name}\""), - &format!("\"{pkg_name}\""), - )?; - - replace_in_file(&"./Cargo.toml".into(), "\n[workspace]", "")?; - - Ok(()) -} diff --git a/2023/day12/src/main.rs b/2023/day12/src/main.rs deleted file mode 100644 index 5ee7ff1..0000000 --- a/2023/day12/src/main.rs +++ /dev/null @@ -1,24 +0,0 @@ -fn part1(input: &str) -> usize { - todo!() -} -fn part2(input: &str) -> usize { - todo!() -} -fn main() { - let input = include_str!("../input.txt"); - println!("Part 1: {}", part1(input)); - println!("Part 2: {}", part2(input)); -} - -#[cfg(test)] -mod tests { - const INPUT: &str = ""; - #[test] - fn part1() { - assert_eq!(super::part1(INPUT), todo!()); - } - #[test] - fn part2() { - assert_eq!(super::part2(INPUT), todo!()); - } -}