File tree 1 file changed +12
-4
lines changed 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -139,9 +139,12 @@ impl ArgMatches {
139
139
/// ```
140
140
#[ cfg_attr( debug_assertions, track_caller) ]
141
141
pub fn get_count ( & self , id : & str ) -> u8 {
142
- * self
143
- . get_one :: < u8 > ( id)
144
- . expect ( "ArgAction::Count is defaulted" )
142
+ * self . get_one :: < u8 > ( id) . unwrap_or_else ( || {
143
+ panic ! (
144
+ "arg `{}`'s `ArgAction` should be `Count` which should provide a default" ,
145
+ id
146
+ )
147
+ } )
145
148
}
146
149
147
150
/// Gets the value of a specific [`ArgAction::SetTrue`][crate::ArgAction::SetTrue] or [`ArgAction::SetFalse`][crate::ArgAction::SetFalse] flag
@@ -173,7 +176,12 @@ impl ArgMatches {
173
176
pub fn get_flag ( & self , id : & str ) -> bool {
174
177
* self
175
178
. get_one :: < bool > ( id)
176
- . expect ( "ArgAction::SetTrue / ArgAction::SetFalse is defaulted" )
179
+ . unwrap_or_else ( || {
180
+ panic ! (
181
+ "arg `{}`'s `ArgAction` should be one of `SetTrue`, `SetFalse` which should provide a default" ,
182
+ id
183
+ )
184
+ } )
177
185
}
178
186
179
187
/// Iterate over values of a specific option or positional argument.
You can’t perform that action at this time.
0 commit comments