getopts
getopts copied to clipboard
opt_present with invalid value should not panic
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.
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.