# manual-rotate

Prefer integer rotation operations over equivalent shift expressions

Combining complementary shifts of one unsigned integer with bitwise OR performs a bit rotation.
Instead, you SHOULD call `.rotateLeft()` or `.rotateRight()` with the corresponding amount.

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

## Reported

```ds title="main.ds"
function rotate(value: uint32): uint32 {
    return (value >> 8) | (value << 24);
}
```

## Accepted

```ds title="main.ds"
function rotate(value: uint32): uint32 {
    return value.rotateRight(8);
}
```

## Prior art

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

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