# no-single-binding-match

Prefer direct evaluation over a match with one irrefutable arm

A match with one unguarded binding arm accepts every value and performs no selection.
Instead, you SHOULD bind the value directly in a `do` expression.

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

## Reported

```ds title="main.ds"
function double(value: int32): int32 {
    return match (value) {
        matched => matched * 2
    };
}
```

## Accepted

```ds title="main.ds"
function double(value: int32): int32 {
    return do {
        const matched = value;
        matched * 2
    };
}
```

## Prior art

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

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