rust-lang / rust-lang/rust-clippy
Change suggestion of manual_range_contains
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Let's see the example of that lint:
assert!(x >= 3 && x < 8);
should be converted to
assert!((3..8).contains(&x));
Here's a review of @kennytm on that topic https://github.com/kennytm/rustup-toolchain-install-master/pull/41#pullrequestreview-727357278
TL:DR; He suggests using the matches! macro and I really like that, because it is a short solution for a complex expression.
assert!(matches!(x, 3..=7))
So here's the question:
Is it worth to suggest using matches! instead of (range).contains? What do you think?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the existing manual_range_contains lint and the linked review discussing its suggestion. Compare the range.contains and matches! examples, then establish which form the lint should recommend and update the relevant behavior and coverage accordingly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100