Skip to content

Commit

Permalink
fix: a few clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fspoettel committed Sep 18, 2024
1 parent 54f3c61 commit e2062e3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/template/commands/scaffold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/template/readme_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::template::Day;

static MARKER: &str = "<!--- benchmarking table --->";

#[allow(dead_code)]
#[derive(Debug)]
pub enum Error {
Parser(String),
Expand Down
1 change: 1 addition & 0 deletions src/template/run_multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 2 additions & 7 deletions src/template/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![];

Expand Down

0 comments on commit e2062e3

Please sign in to comment.