@@ -9,7 +9,7 @@ use std::{cmp, env, process};
99use crate :: template:: ANSI_BOLD ;
1010use crate :: template:: { aoc_cli, Day , ANSI_ITALIC , ANSI_RESET } ;
1111
12- pub fn run_part < I : Clone , T : Display > ( func : impl Fn ( I ) ->Option < T > , input : I , day : Day , part : u8 ) {
12+ pub fn run_part < I : Copy , T : Display > ( func : impl Fn ( I ) ->Option < T > , input : I , day : Day , part : u8 ) {
1313let part_str =format ! ( "Part {part}" ) ;
1414
1515let ( 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- fn run_timed < I : Clone , T > (
28+ fn run_timed < I : Copy , T > (
2929func : impl Fn ( I ) ->T ,
3030input : I ,
3131hook : impl Fn ( & T ) ,
3232) ->( T , Duration , u128 ) {
3333let timer =Instant :: now ( ) ;
3434let result ={
35- let input = input. clone ( ) ;
36-
3735#[ cfg( feature ="dhat-heap" ) ]
3836let _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- fn bench < I : Clone , T > ( func : impl Fn ( I ) ->T , input : I , base_time : & Duration ) ->( Duration , u128 ) {
53+ fn bench < I : Copy , T > ( func : impl Fn ( I ) ->T , input : I , base_time : & Duration ) ->( Duration , u128 ) {
5654let mut stdout =stdout ( ) ;
5755
5856print ! ( " > {ANSI_ITALIC}benching{ANSI_RESET}" ) ;
@@ -64,10 +62,8 @@ fn bench<I: Clone, T>(func: impl Fn(I) -> T, input: I, base_time: &Duration) ->
6462let mut timers: Vec < Duration > =vec ! [ ] ;
6563
6664for _in 0 ..bench_iterations{
67- // need a clone here to make the borrow checker happy.
68- let cloned = input. clone ( ) ;
6965let timer =Instant :: now ( ) ;
70- black_box ( func ( black_box ( cloned ) ) ) ;
66+ black_box ( func ( black_box ( input ) ) ) ;
7167 timers. push ( timer. elapsed ( ) ) ;
7268}
7369