Skip to content

Suggest using == instead of matches! #14688

Description

@emilk

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

if !matches!(value, Enum::Variant) {

Could be written as:

if value != Enum::Variant {

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

A-lintArea: New lints

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions