include_str_ipp

Macro include_str_ipp 

Source
include_str_ipp!() { /* proc-macro */ }
Expand description

Includes a UTF-8 encoded file as a string after processing C-preprocessor style #include directives to inline other UTF-8 encoded files into the string.

The macro takes a single string literal argument that represents the path of the file to be included:

use include_preprocessor_macro::include_str_ipp;

let s = include_str_ipp!("my_file.txt")

The path is resolved relative to the parent directory of the Rust file that invokes the macro.

The macro uses the include-preprocessor crate to parse and resolve C-preprocessor style #include directives. For details on how #include directives are parsed and resolved, refer to the The #include Directive and File Resolution sections of the include-preprocessor documentation. For file resolution, this macro uses a SearchPaths object to which the value of the CARGO_MANIFEST_DIR environment variable (set by Cargo when running Cargo command like cargo build; the directory containing the manifest of your package) is added as a “base path”.

Also supports the #pragma once directive, which prevents files from being included multiple times. Refer to the The #pragma once Directive section of the include-preprocessor documentation for details.

This macro will yield an expression of type &'static str which is the result of running the include-preprocessor using the macro’s argument as the entry-point.