# prefer-slice-parameter

Prefer slice parameters over borrowed arrays

A borrowed array parameter requires callers to provide one specific owned collection when a contiguous view is sufficient.
Instead, you SHOULD accept a borrowed slice so arrays, slices, and other contiguous storage can be passed directly.

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

## Reported

```ds title="main.ds"
function first(values: &readonly int32[]): int32 {
    return values[0];
}
```

## Accepted

```ds title="main.ds"
function first(values: &readonly [int32]): int32 {
    return values[0];
}
```

## Prior art

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

[language/linter/src/rules/performance/prefer_slice_parameter.rs:12](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/performance/prefer_slice_parameter.rs#L12)
