2 releases

0.1.1 Mar 13, 2021
0.1.0 Mar 13, 2021

#18 in #caller


Used in caller_modpath

MIT/Apache

5KB

caller_modpath

crates.io docs.rs

This crates allows for getting the module path of the caller within a #[proc_macro_attribute].

For more information, read the docs.

Example

The simplest example is as follows:

#[caller_modpath::expose_caller_modpath]
#[proc_macro_attribute]
pub fn test(_attr: TokenStream, _input: TokenStream) -> TokenStream {
    let modpath: String = proc_macro::Span::caller_modpath();
    // now do something with it. For example, just panic to have the compiler display the result:
    panic!(
        "module path of call site: {}",
        modpath
    );
}

Dependencies

~1.5MB
~37K SLoC