# prefer-nested-or-pattern

Prefer nesting or-patterns inside their shared nominal pattern

Repeating the same nominal pattern in every or-pattern branch obscures the field that varies.
Instead, you SHOULD place the alternatives in the shared field pattern.

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

## Reported

```ds title="main.ds"
function isSmall(result: Result<int32, string>): boolean {
    return match (result) {
        Ok { value: 0 } | Ok { value: 1 } => true
        _ => false
    };
}
```

## Accepted

```ds title="main.ds"
function isSmall(result: Result<int32, string>): boolean {
    return match (result) {
        Ok { value: 0 | 1 } => true
        _ => false
    };
}
```

## Prior art

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

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