# clone-on-copy

Disallow cloning values whose checked type is Copy

Calling `clone` on a Copy value implies that duplication may require explicit work.
Instead, you SHOULD use the value directly and let Copy semantics duplicate it implicitly.

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

## Reported

```ds title="main.ds"
function duplicate(value: int32): int32 {
    return value.clone();
}
```

## Accepted

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

## Prior art

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

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