You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looks for unnecessary uses of matches! that can be replaced with == or !=
Advantage
Using matches! can produce unnecessarily complex code. When negated, you also get the "double-bang" confusion of !matches!(…), where tje twp ! means different things.
Drawbacks
No response
Example
if !matches!(value,Enum::Variant){ …
Could be written as:
if value != Enum::Variant{ …
The text was updated successfully, but these errors were encountered:
FWIW: Notice that value != Enum::Variant requires Enum: PartialEq, while matches! does not; this also means Enum<T: PartialEq>, even if Enum::Variant does not carry a T. We have a warn-by-default lint wrt value == None in place so people don't fall into this specific pattern. IMHO its not advisable to teach people to do by-value comparison if structural comparison is what they need.
Uh oh!
There was an error while loading. Please reload this page.
What it does
Looks for unnecessary uses of
matches!
that can be replaced with==
or!=
Advantage
Using
matches!
can produce unnecessarily complex code. When negated, you also get the "double-bang" confusion of!matches!(…)
, where tje twp!
means different things.Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: