File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -139,9 +139,12 @@ impl ArgMatches {
139139 /// ```
140140 #[ cfg_attr( debug_assertions, track_caller) ]
141141 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+ } )
145148 }
146149
147150 /// Gets the value of a specific [`ArgAction::SetTrue`][crate::ArgAction::SetTrue] or [`ArgAction::SetFalse`][crate::ArgAction::SetFalse] flag
@@ -173,7 +176,12 @@ impl ArgMatches {
173176 pub fn get_flag ( & self , id : & str ) -> bool {
174177 * self
175178 . 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+ } )
177185 }
178186
179187 /// Iterate over values of a specific option or positional argument.
You can’t perform that action at this time.
0 commit comments