Make the template pass cargo clippy by resolving warnings (#28)
* Resolve clippy::uninlined_format_args warnings * See https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
This commit is contained in:
parent
c8c3dc04be
commit
1c8ea27eae
5 changed files with 20 additions and 23 deletions
|
@ -22,7 +22,7 @@ fn main() {
|
||||||
let args = match parse_args() {
|
let args = match parse_args() {
|
||||||
Ok(args) => args,
|
Ok(args) => args,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to process arguments: {}", e);
|
eprintln!("Failed to process arguments: {e}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -39,7 +39,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("failed to spawn aoc-cli: {}", e);
|
eprintln!("failed to spawn aoc-cli: {e}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ fn main() {
|
||||||
let args = match parse_args() {
|
let args = match parse_args() {
|
||||||
Ok(args) => args,
|
Ok(args) => args,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to process arguments: {}", e);
|
eprintln!("Failed to process arguments: {e}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -39,7 +39,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("failed to spawn aoc-cli: {}", e);
|
eprintln!("failed to spawn aoc-cli: {e}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,16 +62,16 @@ fn main() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let day_padded = format!("{:02}", day);
|
let day_padded = format!("{day:02}");
|
||||||
|
|
||||||
let input_path = format!("src/inputs/{}.txt", day_padded);
|
let input_path = format!("src/inputs/{day_padded}.txt");
|
||||||
let example_path = format!("src/examples/{}.txt", day_padded);
|
let example_path = format!("src/examples/{day_padded}.txt");
|
||||||
let module_path = format!("src/bin/{}.rs", day_padded);
|
let module_path = format!("src/bin/{day_padded}.rs");
|
||||||
|
|
||||||
let mut file = match safe_create_file(&module_path) {
|
let mut file = match safe_create_file(&module_path) {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to create module file: {}", e);
|
eprintln!("Failed to create module file: {e}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -81,7 +81,7 @@ fn main() {
|
||||||
println!("Created module file \"{}\"", &module_path);
|
println!("Created module file \"{}\"", &module_path);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to write module contents: {}", e);
|
eprintln!("Failed to write module contents: {e}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ fn main() {
|
||||||
println!("Created empty input file \"{}\"", &input_path);
|
println!("Created empty input file \"{}\"", &input_path);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to create input file: {}", e);
|
eprintln!("Failed to create input file: {e}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ fn main() {
|
||||||
println!("Created empty example file \"{}\"", &example_path);
|
println!("Created empty example file \"{}\"", &example_path);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to create example file: {}", e);
|
eprintln!("Failed to create example file: {e}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -44,7 +44,7 @@ macro_rules! solve {
|
||||||
pub fn read_file(folder: &str, day: u8) -> String {
|
pub fn read_file(folder: &str, day: u8) -> String {
|
||||||
let cwd = env::current_dir().unwrap();
|
let cwd = env::current_dir().unwrap();
|
||||||
|
|
||||||
let filepath = cwd.join("src").join(folder).join(format!("{:02}.txt", day));
|
let filepath = cwd.join("src").join(folder).join(format!("{day:02}.txt"));
|
||||||
|
|
||||||
let f = fs::read_to_string(filepath);
|
let f = fs::read_to_string(filepath);
|
||||||
f.expect("could not open input file")
|
f.expect("could not open input file")
|
||||||
|
@ -197,13 +197,13 @@ pub mod aoc_cli {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_input_path(day: u8) -> String {
|
fn get_input_path(day: u8) -> String {
|
||||||
let day_padded = format!("{:02}", day);
|
let day_padded = format!("{day:02}");
|
||||||
format!("src/inputs/{}.txt", day_padded)
|
format!("src/inputs/{day_padded}.txt")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_puzzle_path(day: u8) -> String {
|
fn get_puzzle_path(day: u8) -> String {
|
||||||
let day_padded = format!("{:02}", day);
|
let day_padded = format!("{day:02}");
|
||||||
format!("src/puzzles/{}.md", day_padded)
|
format!("src/puzzles/{day_padded}.md")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_args(command: &str, args: &[String], day: u8, year: Option<u16>) -> Vec<String> {
|
fn build_args(command: &str, args: &[String], day: u8, year: Option<u16>) -> Vec<String> {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::process::Command;
|
||||||
fn main() {
|
fn main() {
|
||||||
let total: f64 = (1..=25)
|
let total: f64 = (1..=25)
|
||||||
.map(|day| {
|
.map(|day| {
|
||||||
let day = format!("{:02}", day);
|
let day = format!("{day:02}");
|
||||||
|
|
||||||
let mut args = vec!["run", "--bin", &day];
|
let mut args = vec!["run", "--bin", &day];
|
||||||
if cfg!(not(debug_assertions)) {
|
if cfg!(not(debug_assertions)) {
|
||||||
|
@ -18,7 +18,7 @@ fn main() {
|
||||||
let cmd = Command::new("cargo").args(&args).output().unwrap();
|
let cmd = Command::new("cargo").args(&args).output().unwrap();
|
||||||
|
|
||||||
println!("----------");
|
println!("----------");
|
||||||
println!("{}| Day {} |{}", ANSI_BOLD, day, ANSI_RESET);
|
println!("{ANSI_BOLD}| Day {day} |{ANSI_RESET}");
|
||||||
println!("----------");
|
println!("----------");
|
||||||
|
|
||||||
let output = String::from_utf8(cmd.stdout).unwrap();
|
let output = String::from_utf8(cmd.stdout).unwrap();
|
||||||
|
@ -41,8 +41,5 @@ fn main() {
|
||||||
})
|
})
|
||||||
.sum();
|
.sum();
|
||||||
|
|
||||||
println!(
|
println!("{ANSI_BOLD}Total:{ANSI_RESET} {ANSI_ITALIC}{total:.2}ms{ANSI_RESET}");
|
||||||
"{}Total:{} {}{:.2}ms{}",
|
|
||||||
ANSI_BOLD, ANSI_RESET, ANSI_ITALIC, total, ANSI_RESET
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue