summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/size_of_in_element_count.txt
blob: d893ec6a2a014ef486b78836a216072f7f84d7fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
### What it does
Detects expressions where
`size_of::<T>` or `size_of_val::<T>` is used as a
count of elements of type `T`

### Why is this bad?
These functions expect a count
of `T` and not a number of bytes

### Example
```
const SIZE: usize = 128;
let x = [2u8; SIZE];
let mut y = [2u8; SIZE];
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
```