rust/tests/run-make/import-macro-verbatim/verbatim.rs
Chris Denton edc97a0df2
Fix verbatim paths used with include!
When using `concat!` to join paths, the Unix path separator (`/`) is often used. This breaks on Windows if the base path is a verbatim path (i.e. starts with `\\?\`).
2024-07-31 12:44:47 +00:00

13 lines
484 B
Rust

//! Include a file by concating the verbatim path using `/` instead of `\`
include!(concat!(env!("VERBATIM_DIR"), "/include/include.txt"));
fn main() {
assert_eq!(TEST, "Hello World!");
let s = include_str!(concat!(env!("VERBATIM_DIR"), "/include/include.txt"));
assert_eq!(s, "static TEST: &str = \"Hello World!\";\n");
let b = include_bytes!(concat!(env!("VERBATIM_DIR"), "/include/include.txt"));
assert_eq!(b, b"static TEST: &str = \"Hello World!\";\n");
}