# manual-result-tap

Prefer Result tap methods when mapping observes and returns its payload

Mapping a Result payload only to observe it before returning it unchanged obscures the side effect.
Instead, you SHOULD use `tap` for successful values and `tapErr` for errors.

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

## Reported

```ds title="main.ds"
declare function record(value: &readonly int32): void;

function inspect(result: Result<int32, string>): Result<int32, string> {
    return result.map((value) => {
        record(value);
        value
    });
}
```

## Accepted

```ds title="main.ds"
declare function record(value: &readonly int32): void;

function inspect(result: Result<int32, string>): Result<int32, string> {
    return result.tap((value) => {
        record(value);
    });
}
```

## Prior art

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

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