Skip to main content

invocation_directory

Function invocation_directory 

Source
pub fn invocation_directory(
    input: &TokenTree,
    origin: &Origin,
    accept: impl FnMut(&Path) -> bool,
) -> Option<PathBuf>
Expand description

The directory of the .rs file an invocation whose whole input is input is written in, found by searching the crate’s sources.

This is what include_c99!("…") needs where the compiler gives no position: a relative path is resolved against the directory of the .rs file the macro is written in, and that directory has to come from somewhere. accept is asked about each candidate directory, so that of several invocations spelled the same way the one whose directory really holds the file wins; None when nothing can be proved, and the caller falls back to CARGO_MANIFEST_DIR.