# manual-ok-err

Prefer Result projection methods over equivalent pattern matching

Branching on a Result to select one payload or undefined manually projects the Result.
Instead, you SHOULD use `ok` or `err` to project the selected payload.

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

## Reported

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

## Accepted

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

## Prior art

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

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