caller_modpath_macros

Crates.iocaller_modpath_macros
lib.rscaller_modpath_macros
version0.1.1
sourcesrc
created_at2021-03-13 19:33:49.623252
updated_at2021-03-13 19:45:50.139024
descriptionproc_macros for caller_modpath
homepage
repositoryhttps://github.com/Shizcow/caller_modpath
max_upload_size
id368421
size4,284
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