Skip to content

Commit e2062e3

Browse files
committed
fix: a few clippy warnings
1 parent 54f3c61 commit e2062e3

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/template/commands/scaffold.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ fn safe_create_file(path: &str) -> Result<File, std::io::Error> {
1414
}
1515

1616
fn create_file(path: &str) -> Result<File, std::io::Error> {
17-
OpenOptions::new().write(true).create(true).open(path)
17+
OpenOptions::new()
18+
.write(true)
19+
.create(true)
20+
.truncate(true)
21+
.open(path)
1822
}
1923

2024
pub fn handle(day: Day) {

src/template/readme_benchmarks.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::template::Day;
77

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

10+
#[allow(dead_code)]
1011
#[derive(Debug)]
1112
pub enum Error {
1213
Parser(String),

src/template/run_multi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub fn run_multi(days_to_run: &HashSet<Day>, is_release: bool, is_timed: bool) -
4646
}
4747
}
4848

49+
#[allow(dead_code)]
4950
#[derive(Debug)]
5051
pub enum Error {
5152
BrokenPipe,

src/template/runner.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,8 @@ fn bench<I: Clone, T>(func: impl Fn(I) -> T, input: I, base_time: &Duration) ->
5858
print!(" > {ANSI_ITALIC}benching{ANSI_RESET}");
5959
let _ = stdout.flush();
6060

61-
let bench_iterations = cmp::min(
62-
10000,
63-
cmp::max(
64-
Duration::from_secs(1).as_nanos() / cmp::max(base_time.as_nanos(), 10),
65-
10,
66-
),
67-
);
61+
let bench_iterations =
62+
(Duration::from_secs(1).as_nanos() / cmp::max(base_time.as_nanos(), 10)).clamp(10, 10000);
6863

6964
let mut timers: Vec<Duration> = vec![];
7065

0 commit comments

Comments
 (0)