]> git.lizzy.rs Git - rust.git/blob - src/docs/large_include_file.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / large_include_file.txt
1 ### What it does
2 Checks for the inclusion of large files via `include_bytes!()`
3 and `include_str!()`
4
5 ### Why is this bad?
6 Including large files can increase the size of the binary
7
8 ### Example
9 ```
10 let included_str = include_str!("very_large_file.txt");
11 let included_bytes = include_bytes!("very_large_file.txt");
12 ```
13
14 Use instead:
15 ```
16 use std::fs;
17
18 // You can load the file at runtime
19 let string = fs::read_to_string("very_large_file.txt")?;
20 let bytes = fs::read("very_large_file.txt")?;
21 ```