summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/transmute_num_to_bytes.txt
blob: a2c39a1b947e31966e0a8d12409333be8b99da62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
### What it does
Checks for transmutes from a number to an array of `u8`

### Why this is bad?
Transmutes are dangerous and error-prone, whereas `to_ne_bytes`
is intuitive and safe.

### Example
```
unsafe {
    let x: [u8; 8] = std::mem::transmute(1i64);
}

// should be
let x: [u8; 8] = 0i64.to_ne_bytes();
```