caller_modpath

Crates.iocaller_modpath
lib.rscaller_modpath
version0.1.1
sourcesrc
created_at2021-03-13 19:35:22.687479
updated_at2021-03-13 19:47:27.627183
descriptionGet the module path of the caller in a proc_macro
homepage
repositoryhttps://github.com/Shizcow/caller_modpath
max_upload_size
id368422
size12,148
Devin Pohl (Shizcow)

documentation

README

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
    );
}
Commit count: 35

cargo fmt