Crate proc_macro_tools
source · [−]Expand description
Tools for writing procedural macroses.
Module :: proc_macro_tools
Tools for writing procedural macroses.
Sample
use proc_macro_tools::*;
let code = qt!( core::option::Option< i8, i16, i32, i64 > );
let tree_type = syn::parse2::< syn::Type >( code ).unwrap();
let got = type_parameters( &tree_type, 0..=2 );
got.iter().for_each( | e | println!( "{}", qt!( #e ) ) );
// < i8
// < i16
// < i32
To add to your project
cargo add proc_macro_tools
Try out from the repository
git clone https://github.com/Wandalen/wTools
cd wTools
cd sample/rust/proc_macro_tools_trivial
cargo run
Re-exports
pub use protected::*;
Modules
Container kind.
Dependencies of the module.
Exposed namespace of the module.
Helpers.
Trait name.
Parented namespace of the module.
Prelude to use essentials: use my_module::prelude::*
.
Own namespace of the module.
Split with name.
Syntax.
Macros
Macro to generate syn error either with span of a syntax tree element or with default one proc_macro2::Span::call_site()
.
Macro for diagnostics purpose to export both syntax tree and source code behind it into string.
Macro for diagnostics purpose to print both syntax tree and source code behind it.