synext
A simple extension library for syn crate to help developers quickly develop derive macros
1. Acknowledgment
This project, synext, was developed with significant inspiration from the open-source
project proc_macros. Special
thanks to the contributors of proc_macros for their excellent work.
2. Usage
Add this to your Cargo.toml:
[]
= "0.2"
3. APIs
3.1.Fields
3.1.1. named
// input = TokenStream
let derive_input = try_derive_input;
let named_fields = try_parse_named_fields;
3.1.2. unnamed
// input = TokenStream
let derive_input = try_derive_input;
let unnamed_fields = try_parse_unnamed_fields;
3.1.3. match
// input = TokenStream
let derive_input = try_derive_input;
let fields = try_match_fields;
3.2. Types
3.2.1. Option
unwrap Option inner type.
3.2.2. Vec
unwrap Vec inner type.
3.2.3. unwrap_types
3.2.4. inner_types
3.3. Predicate
-
Option-
// @since 0.2.0
-
-
Vec-
// @since 0.2.0
-
-
Ident -
-
segments -
3.4.Derive attribute
Try to extract the specified path attribute value from a field's attributes.
// @since 0.2.0
3.5.Attribute macro
3.5.1.kv
extern crate proc_macro;
use TokenStream;
use Arc;
// kv
;
3.5.2.first
extern crate proc_macro;
use TokenStream;
use Arc;
// first
;