std::file! [-] [+] [src]

macro_rules! file { () => ({ /* compiler built-in */ }) }

A macro which expands to the file name from which it was invoked.

The expanded expression has type &'static str, and the returned file is not the invocation of the file!() macro itself, but rather the first macro invocation leading up to the invocation of the file!() macro.

Example

fn main() { let this_file = file!(); println!("defined in file: {}", this_file); }
let this_file = file!();
println!("defined in file: {}", this_file);