# no-needless-match

Disallow matches that reconstruct their scrutinee unchanged

A match whose every arm returns the exact value selected by its pattern leaves the scrutinee unchanged.
Instead, you SHOULD use the scrutinee directly.

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

## Reported

```ds title="main.ds"
function preserve(value: int32): int32 {
    return match (value) {
        0 => 0
        1 => 1
        value => value
    };
}
```

## Accepted

```ds title="main.ds"
function preserve(value: int32): int32 {
    return value;
}
```

## Prior art

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

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