# needless-borrow-of-copy

Prefer passing small Copy scalars by value

A readonly borrow of a machine scalar adds indirection to a value that Copy can pass directly.
Instead, you SHOULD pass the scalar by value and rely on its intrinsic Copy behavior.

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

## Reported

```ds title="main.ds"
function increment(value: &readonly int32): int32 {
    return value + 1;
}
```

## Accepted

```ds title="main.ds"
function increment(value: int32): int32 {
    return value + 1;
}
```

## Prior art

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

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