# manual-take

Prefer take over moving a value and assigning its default

Moving a place into a temporary and then assigning its default value manually takes the place's value.
Instead, you SHOULD call `take` with an exclusive borrow of the place.

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

## Reported

```ds title="main.ds"
function remove<T: Default>(initial: T): T {
    let value = initial;
    const previous = value;
    value = T.default();
    return previous;
}
```

## Accepted

```ds title="main.ds"
import { take } from "destack:memory";

function remove<T: Default>(initial: T): T {
    let value = initial;
    return take(&exclusive value);
}
```

## Prior art

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

[language/linter/src/rules/style/manual_take.rs:7](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/manual_take.rs#L7)
