Replace {assert, debug_assert}
using ==
or !=
by the _eq
or _ne
variants
#7837
Labels
A-lint
Area: New lints
What it does
It checks for asserts like
assert!(1 == 1);
and suggests to replace it withassert_eq!(1, 1);
.As far as I know, this is more idiomatic.
Categories (optional)
clippy::style
or maybeclippy::complexity
.The advantage is idiomacy and consistency/consistent style.
It can also improve readability and the
_eq
/_ne
variants make it much easier to search for specific kind of asserts (no regex for example needed).Drawbacks
None.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: