Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit19aaf52

Browse files
committed
2 parents4f0f444 +36608db commit19aaf52

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

‎.vscode/launch.json‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
"args": [
1313
"test",
1414
"--no-run",
15-
// replace `01` here with the solution you like to debug.
16-
"--bin=01",
15+
// replace with binary name (e.g. "01") here if you always
16+
// want to debug one file regardless of the active file in
17+
// the editor.
18+
"--bin=${fileBasenameNoExtension}",
1719
"--package=advent_of_code"
1820
],
1921
},
@@ -27,8 +29,10 @@
2729
"cargo": {
2830
"args": [
2931
"build",
30-
// replace `01` here with the solution you like to debug.
31-
"--bin=01",
32+
// replace with binary name (e.g. "01") here if you always
33+
// want to debug one file regardless of the active file in
34+
// the editor
35+
"--bin=${fileBasenameNoExtension}",
3236
"--package=advent_of_code"
3337
],
3438
},

‎src/template/runner.rs‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{cmp, env, process};
99
usecrate::template::ANSI_BOLD;
1010
usecrate::template::{aoc_cli,Day,ANSI_ITALIC,ANSI_RESET};
1111

12-
pubfnrun_part<I:Clone,T:Display>(func:implFn(I) ->Option<T>,input:I,day:Day,part:u8){
12+
pubfnrun_part<I:Copy,T:Display>(func:implFn(I) ->Option<T>,input:I,day:Day,part:u8){
1313
let part_str =format!("Part {part}");
1414

1515
let(result, duration, samples) =
@@ -25,15 +25,13 @@ pub fn run_part<I: Clone, T: Display>(func: impl Fn(I) -> Option<T>, input: I, d
2525
/// Run a solution part. The behavior differs depending on whether we are running a release or debug build:
2626
/// 1. in debug, the function is executed once.
2727
/// 2. in release, the function is benched (approx. 1 second of execution time or 10 samples, whatever take longer.)
28-
fnrun_timed<I:Clone,T>(
28+
fnrun_timed<I:Copy,T>(
2929
func:implFn(I) ->T,
3030
input:I,
3131
hook:implFn(&T),
3232
) ->(T,Duration,u128){
3333
let timer =Instant::now();
3434
let result ={
35-
let input = input.clone();
36-
3735
#[cfg(feature ="dhat-heap")]
3836
let _profiler = dhat::Profiler::new_heap();
3937

@@ -52,7 +50,7 @@ fn run_timed<I: Clone, T>(
5250
(result, run.0, run.1)
5351
}
5452

55-
fnbench<I:Clone,T>(func:implFn(I) ->T,input:I,base_time:&Duration) ->(Duration,u128){
53+
fnbench<I:Copy,T>(func:implFn(I) ->T,input:I,base_time:&Duration) ->(Duration,u128){
5654
letmut stdout =stdout();
5755

5856
print!(" > {ANSI_ITALIC}benching{ANSI_RESET}");
@@ -64,10 +62,8 @@ fn bench<I: Clone, T>(func: impl Fn(I) -> T, input: I, base_time: &Duration) ->
6462
letmut timers:Vec<Duration> =vec![];
6563

6664
for _in0..bench_iterations{
67-
// need a clone here to make the borrow checker happy.
68-
let cloned = input.clone();
6965
let timer =Instant::now();
70-
black_box(func(black_box(cloned)));
66+
black_box(func(black_box(input)));
7167
timers.push(timer.elapsed());
7268
}
7369

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp