# manual-unwrap-or

Prefer Result fallback methods over equivalent pattern matching

Branching on a Result to select its successful payload or a fallback manually unwraps the Result.
Instead, you SHOULD use `unwrapOr` for eager values or `unwrapOrElse` for computed fallbacks.

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

## Reported

```ds title="main.ds"
function value(result: Result<int32, string>): int32 {
    return match (result) {
        Ok { value } => value
        Err { error: _ } => 0
    };
}
```

## Accepted

```ds title="main.ds"
function value(result: Result<int32, string>): int32 {
    return result.unwrapOr(0);
}
```

## Prior art

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

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