macro_rules! embed_bytes {
($path:literal) => { ... };
}
Expand description
Embeds the file contents as bytes into the binary in release mode, but loads it from the filesystem in debug.
The file path should be relative to the source file from which the macro is
called (similar to include_bytes
).
The macro returns a Cow<'static, [u8]>
, which can either be a reference to
the static byte slice included in the binary, or an owned byte vector 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_bytes = embed_bytes!("path/to/my_file.bin");
println!("File size: {}", my_file_bytes.len());