]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/size_of_in_element_count.txt
Auto merge of #98559 - jackh726:remove-reempty, r=oli-obk
[rust.git] / src / tools / clippy / src / docs / size_of_in_element_count.txt
1 ### What it does
2 Detects expressions where
3 `size_of::<T>` or `size_of_val::<T>` is used as a
4 count of elements of type `T`
5
6 ### Why is this bad?
7 These functions expect a count
8 of `T` and not a number of bytes
9
10 ### Example
11 ```
12 const SIZE: usize = 128;
13 let x = [2u8; SIZE];
14 let mut y = [2u8; SIZE];
15 unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
16 ```