Embed file contents directly into your Rust binary at compile time using include_str! for text and include_bytes! for raw data.
Use include_str! to embed a file's text content as a &'static str and include_bytes! to embed raw bytes as a &'static [u8] directly into your binary at compile time.
const CONFIG: &str = include_str!("config.txt");
const DATA: &[u8] = include_bytes!("data.bin");
These macros read the specified file paths relative to the current crate root and replace the macro invocation with the file contents during compilation.
These macros let you bake files directly into your program's code when you build it. Instead of reading a file from the disk while the program runs, the file's content becomes part of the executable itself. Think of it like pasting the text of a document directly into your source code, but the compiler does the pasting for you automatically.