Crates.io | caller_modpath_macros |
lib.rs | caller_modpath_macros |
version | 0.1.1 |
source | src |
created_at | 2021-03-13 19:33:49.623252 |
updated_at | 2021-03-13 19:45:50.139024 |
description | proc_macros for caller_modpath |
homepage | |
repository | https://github.com/Shizcow/caller_modpath |
max_upload_size | |
id | 368421 |
size | 4,284 |
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
);
}