forbid use of Rng::gen_range
This function panics if the range is empty. Prompted by #918 (closed) I did a git grep and there were call sites where it wasn't straightforward to convince myself that everything is fine.
I think we should:
- Make an extension trait to
Rng
which providesgen_range_checked
which returnsOption
- Change every call site to use that; where panicking on empty ranges is warranted, that should be done explicitly at the call site with
expect
- Somehow arrange to forbid use of
gen_range
. I'm not sure if clippy can do this for us, but if not then currently this rune seems to work:
git-grep -P '\bgen_range\b(?!`)'