# map-identity

Disallow rebuilding an owned array through an identity map

Mapping every element to itself rebuilds an owned array without changing its values.
Instead, you SHOULD use the original owned array directly.

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

## Reported

```ds title="main.ds"
function identity(values: ^int32[]): ^int32[] {
    return values.map((value) => value);
}
```

## Accepted

```ds title="main.ds"
function identity(values: ^int32[]): ^int32[] {
    return values;
}
```

## Prior art

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

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