From e2062e33fdb48094937c28d64517ff2c52aede05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sp=C3=B6ttel?= <1682504+fspoettel@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:57:00 +0900 Subject: [PATCH] fix: a few clippy warnings --- src/template/commands/scaffold.rs | 6 +++++- src/template/readme_benchmarks.rs | 1 + src/template/run_multi.rs | 1 + src/template/runner.rs | 9 ++------- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/template/commands/scaffold.rs b/src/template/commands/scaffold.rs index 4e7d7c0..9a0021f 100644 --- a/src/template/commands/scaffold.rs +++ b/src/template/commands/scaffold.rs @@ -14,7 +14,11 @@ fn safe_create_file(path: &str) -> Result { } fn create_file(path: &str) -> Result { - OpenOptions::new().write(true).create(true).open(path) + OpenOptions::new() + .write(true) + .create(true) + .truncate(true) + .open(path) } pub fn handle(day: Day) { diff --git a/src/template/readme_benchmarks.rs b/src/template/readme_benchmarks.rs index 1498dbb..5c42ae4 100644 --- a/src/template/readme_benchmarks.rs +++ b/src/template/readme_benchmarks.rs @@ -7,6 +7,7 @@ use crate::template::Day; static MARKER: &str = ""; +#[allow(dead_code)] #[derive(Debug)] pub enum Error { Parser(String), diff --git a/src/template/run_multi.rs b/src/template/run_multi.rs index 5bafefb..c951faa 100644 --- a/src/template/run_multi.rs +++ b/src/template/run_multi.rs @@ -46,6 +46,7 @@ pub fn run_multi(days_to_run: &HashSet, is_release: bool, is_timed: bool) - } } +#[allow(dead_code)] #[derive(Debug)] pub enum Error { BrokenPipe, diff --git a/src/template/runner.rs b/src/template/runner.rs index b4e41bc..0a48767 100644 --- a/src/template/runner.rs +++ b/src/template/runner.rs @@ -58,13 +58,8 @@ fn bench(func: impl Fn(I) -> T, input: I, base_time: &Duration) -> print!(" > {ANSI_ITALIC}benching{ANSI_RESET}"); let _ = stdout.flush(); - let bench_iterations = cmp::min( - 10000, - cmp::max( - Duration::from_secs(1).as_nanos() / cmp::max(base_time.as_nanos(), 10), - 10, - ), - ); + let bench_iterations = + (Duration::from_secs(1).as_nanos() / cmp::max(base_time.as_nanos(), 10)).clamp(10, 10000); let mut timers: Vec = vec![];