I don't know about other langs, but I found very interesting way around (for rust).. if we have fi

I don't know about other langs, but I found very interesting way around (for rust)..

if we have files predefined, then we can load the content at compile time

example:
macro_rules! load_file {
    ($name:literal) => {
        include_str!(concat!(
            env!("CARGO_MANIFEST_DIR"),
            "/some/path",
            $name
        ))
    };
}


this will read the file content and we store it in memory
Was this page helpful?