# unused-enumerate-index

Disallow indexed iteration when its index is unused

Indexed iteration constructs an index-value pair for every element even when the index is unused.
Instead, you SHOULD iterate over the values directly.

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

## Reported

```ds title="main.ds"
function copy(values: int32[], output: int32[]): void {
    for (const (_, value) of values.entries()) {
        output.push(value);
    }
}
```

## Accepted

```ds title="main.ds"
function copy(values: int32[], output: int32[]): void {
    for (const value of values) {
        output.push(value);
    }
}
```

## Prior art

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

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