2 releases
0.1.1 | Mar 13, 2021 |
---|---|
0.1.0 | Mar 13, 2021 |
#1630 in Development tools
13KB
186 lines
caller_modpath
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
~3.5MB
~69K SLoC