How to Use the include_str! and include_bytes! Macros

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.