@@ -8,11 +8,11 @@ use crate::load_input_data;
8
8
9
9
#[ derive( Debug ) ]
10
10
pub struct Args {
11
- pub input : String , // puzzle input
12
- pub verbose : bool , // activate the verbose flag
13
- options : Vec < String > , // copy of Args() (with a leading -)
14
- pub params : Vec < String > , // copy of Args() (without the leading -)
15
- elapsed : bool , // flag to show elapsed time
11
+ input : String , // puzzle input
12
+ verbose : bool , // activate the verbose flag
13
+ options : Vec < String > , // copy of Args() (with a leading -)
14
+ params : Vec < String > , // copy of Args() (without the leading -)
15
+ elapsed : bool , // flag to show elapsed time
16
16
}
17
17
18
18
impl Args {
@@ -27,6 +27,15 @@ impl Args {
27
27
args
28
28
}
29
29
30
+ pub const fn input ( & self ) -> & String {
31
+ & self . input
32
+ }
33
+
34
+ /// Return `true` if the flag -v/--verbose is on commandline.
35
+ pub const fn is_verbose ( & self ) -> bool {
36
+ self . verbose
37
+ }
38
+
30
39
#[ must_use]
31
40
pub fn parse_args_raw ( ) -> Self {
32
41
let help = std:: env:: args ( ) . any ( |a| a == "--help" || a == "-h" ) ;
@@ -56,6 +65,10 @@ impl Args {
56
65
self . options . iter ( ) . filter ( |s| * s == option) . count ( ) != 0
57
66
//self.options.contains(option)
58
67
}
68
+
69
+ pub fn params ( & self ) -> & [ String ] {
70
+ self . params . as_slice ( )
71
+ }
59
72
}
60
73
61
74
/// Show command-line usage.
@@ -107,8 +120,8 @@ impl Args {
107
120
108
121
let ( p1, p2) = solve ( data) ;
109
122
110
- # [ allow ( clippy :: cast_possible_truncation ) ]
111
- let micros = Duration :: from_micros ( instant . elapsed ( ) . as_micros ( ) as u64 ) ;
123
+ let elapsed = instant . elapsed ( ) ;
124
+ let micros = Duration :: new ( elapsed. as_secs ( ) , elapsed . subsec_micros ( ) * 1000 ) ;
112
125
113
126
println ! ( "{p1}" ) ;
114
127
0 commit comments