# no-redundant-match-guard

Prefer literal patterns over equivalent equality guards

An equality guard on a newly bound match value repeats a test that the pattern can perform directly.
Instead, you SHOULD match the compared literal in the arm pattern.

- Category: style
- Level: warning
- Fix: automatic
- Scope: module

## Reported

```ds title="main.ds"
function classify(value: int32): string {
    return match (value) {
        matched if (matched === 0) => "zero"
        _ => "other"
    };
}
```

## Accepted

```ds title="main.ds"
function classify(value: int32): string {
    return match (value) {
        0 => "zero"
        _ => "other"
    };
}
```

## Prior art

- [Clippy · redundant_guards](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_guards)

[language/linter/src/rules/style/no_redundant_match_guard.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/no_redundant_match_guard.rs#L8)
