Macro embed_string

Source
macro_rules! embed_string {
    ($path:literal) => { ... };
}
Expand description

Embeds the file contents as a string into the binary in release mode, but loads it from fs in debug.

The file path should be relative to the source file from which the macro is called (similar to include_str).

The macro returns a Cow<'static, str>, which can either be a reference to the static string included in the binary, or an owned string read from the file in debug mode.

Note: this macro will panic in debug mode if the file cannot be read (which is what you probably want).

ยงExample

let my_file_contents = embed_string!("path/to/my_file.txt");
println!("{}", my_file_contents);