Macro std::include1.0.0[][src]

macro_rules! include {
    ($file:expr) => { ... };
    ($file:expr,) => { ... };

Parse a file as an expression or an item according to the context.

The file is located relative to the current file (similarly to how modules are found).

Using this macro is often a bad idea, because if the file is parsed as an expression, it is going to be placed in the surrounding code unhygienically. This could result in variables or functions being different from what the file expected if there are variables or functions that have the same name in the current file.


Assume there are two files in the same directory with the following contents:

File '':

This example is not tested
['🙈', '🙊', '🙉']

File '':

This example is not tested
fn main() {
    let my_string = include!("");
    assert_eq!("🙈🙊🙉🙈🙊🙉", my_string);
    println!("{}", my_string);

Compiling '' and running the resulting binary will print "🙈🙊🙉🙈🙊🙉".