Proc Macro Roids
Traits and functions to make writing proc macros more ergonomic.
The roids name is chosen because, although these functions make it easy to perform certain operation, they may not necessarily be a good idea =D!
Examples
-
Append additional
#[derive(..)]
s.This works for function-like or attribute proc macros.
extern crate proc_macro; use TokenStream; use DeriveInputDeriveExt; use quote; use ;
-
Append named fields.
This works for structs with named fields or unit structs.
extern crate proc_macro; use TokenStream; use FieldsNamedAppend; use quote; use ; /// Example usage: /// /// ```rust /// use macro_crate::append_cd; /// /// #[append_cd] /// struct StructNamed { a: u32, b: i32 } /// ```
-
Append unnamed fields (tuples).
This works for structs with unnamed fields or unit structs.
extern crate proc_macro; use TokenStream; use FieldsUnnamedAppend; use quote; use ; /// Example usage: /// /// ```rust /// use macro_crate::append_i64_usize; /// /// #[append_i64_usize] /// struct StructUnit; /// ```
-
Get newtype inner
Field
.This works for structs with unnamed fields or unit structs.
extern crate proc_macro; use TokenStream; use DeriveInputNewtypeExt; use quote; use ;
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.