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> { 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) { pub fn handle(day: Day) {

View file

@ -7,6 +7,7 @@ use crate::template::Day;
static MARKER: &str = "<!--- benchmarking table --->"; static MARKER: &str = "<!--- benchmarking table --->";
#[allow(dead_code)]
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
Parser(String), 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)] #[derive(Debug)]
pub enum Error { pub enum Error {
BrokenPipe, 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}"); print!(" > {ANSI_ITALIC}benching{ANSI_RESET}");
let _ = stdout.flush(); let _ = stdout.flush();
let bench_iterations = cmp::min( let bench_iterations =
10000, (Duration::from_secs(1).as_nanos() / cmp::max(base_time.as_nanos(), 10)).clamp(10, 10000);
cmp::max(
Duration::from_secs(1).as_nanos() / cmp::max(base_time.as_nanos(), 10),
10,
),
);
let mut timers: Vec<Duration> = vec![]; let mut timers: Vec<Duration> = vec![];