| Crates.io | caller_modpath |
| lib.rs | caller_modpath |
| version | 0.1.1 |
| created_at | 2021-03-13 19:35:22.687479+00 |
| updated_at | 2021-03-13 19:47:27.627183+00 |
| description | Get the module path of the caller in a proc_macro |
| homepage | |
| repository | https://github.com/Shizcow/caller_modpath |
| max_upload_size | |
| id | 368422 |
| size | 12,148 |
This crates allows for getting the module path of the caller within a
#[proc_macro_attribute].
For more information, read the docs.
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
);
}