@@ -27,11 +27,13 @@ impl Args {
27
27
args
28
28
}
29
29
30
+ #[ must_use]
30
31
pub const fn input ( & self ) -> & String {
31
32
& self . input
32
33
}
33
34
34
35
/// Return `true` if the flag -v/--verbose is on commandline.
36
+ #[ must_use]
35
37
pub const fn is_verbose ( & self ) -> bool {
36
38
self . verbose
37
39
}
@@ -61,11 +63,13 @@ impl Args {
61
63
}
62
64
}
63
65
66
+ #[ must_use]
64
67
pub fn has_option ( & self , option : & str ) -> bool {
65
68
self . options . iter ( ) . filter ( |s| * s == option) . count ( ) != 0
66
69
//self.options.contains(option)
67
70
}
68
71
72
+ #[ must_use]
69
73
pub fn params ( & self ) -> & [ String ] {
70
74
self . params . as_slice ( )
71
75
}
@@ -101,16 +105,21 @@ fn usage() {
101
105
}
102
106
103
107
impl Args {
108
+ /// Run a day solution, with input data read from file `input.txt`
109
+ /// or the first non flag argument of the commandline.
110
+ /// Display the elapsed time in the flag `--elapsed` is present.
104
111
pub fn run < U , V , T > ( & self , solve : T )
105
112
where
106
113
U : Display ,
107
114
V : Display ,
108
115
T : Fn ( & str ) -> ( U , V ) ,
109
116
{
110
- self . run_data ( solve, & self . input ) ;
117
+ let _ = self . run_data ( solve, & self . input ) ;
111
118
}
112
119
113
- pub fn run_data < U , V , T > ( & self , solve : T , data : & str )
120
+ /// Run a day solution with the given input data.
121
+ /// Display the elapsed time in the flag `--elapsed` is present.
122
+ pub fn run_data < U , V , T > ( & self , solve : T , data : & str ) -> Duration
114
123
where
115
124
U : Display ,
116
125
V : Display ,
@@ -134,5 +143,7 @@ impl Args {
134
143
if self . elapsed {
135
144
println ! ( "elapsed: {micros:?}" ) ;
136
145
}
146
+
147
+ elapsed
137
148
}
138
149
}
0 commit comments