getopts icon indicating copy to clipboard operation
getopts copied to clipboard

opt_present with invalid value should not panic

Open mqudsi opened this issue 7 years ago • 1 comments

If matches.opt_present is called with a not-defined option, that should either be a compile-time error (somehow) or it should return false; currently it panics instead.

mqudsi avatar Aug 12 '17 17:08 mqudsi

The current behaviour of panicking highlights an issue in the program itself where it's trying to find a value that'll never return true. I think this is maybe a little surprising but is a reasonable way to identify a possible bug.

We should note in the crate docs that the method will panic if it's given an option that doesn't exist.

KodrAus avatar Oct 15 '18 02:10 KodrAus