fix: a few clippy warnings

This commit is contained in:
Felix Spöttel 2024-09-18 18:57:00 +09:00
parent 54f3c61092
commit e2062e33fd
4 changed files with 9 additions and 8 deletions

View file

@ -14,7 +14,11 @@ fn safe_create_file(path: &str) -> Result<File, std::io::Error> {
}
fn create_file(path: &str) -> Result<File, std::io::Error> {
OpenOptions::new().write(true).create(true).open(path)
OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(path)
}
pub fn handle(day: Day) {

View file

@ -7,6 +7,7 @@ use crate::template::Day;
static MARKER: &str = "<!--- benchmarking table --->";
#[allow(dead_code)]
#[derive(Debug)]
pub enum Error {
Parser(String),

View file

@ -46,6 +46,7 @@ pub fn run_multi(days_to_run: &HashSet<Day>, is_release: bool, is_timed: bool) -
}
}
#[allow(dead_code)]
#[derive(Debug)]
pub enum Error {
BrokenPipe,

View file

@ -58,13 +58,8 @@ fn bench<I: Clone, T>(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<Duration> = vec![];