]> git.lizzy.rs Git - rust.git/blob - src/docs/large_const_arrays.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / large_const_arrays.txt
1 ### What it does
2 Checks for large `const` arrays that should
3 be defined as `static` instead.
4
5 ### Why is this bad?
6 Performance: const variables are inlined upon use.
7 Static items result in only one instance and has a fixed location in memory.
8
9 ### Example
10 ```
11 pub const a = [0u32; 1_000_000];
12 ```
13
14 Use instead:
15 ```
16 pub static a = [0u32; 1_000_000];
17 ```