#proc-macro #extension-traits #syn

parse-more

Extension of the Parse trait from syn, allowing to parse input from procedural macros directly, without having to create a custom structure and implementing the Parse trait on it

2 unstable releases

Uses new Rust 2024

new 0.2.0 Sep 25, 2025
0.1.0 Sep 19, 2025

#1237 in Procedural macros

Download history 100/week @ 2025-09-14 145/week @ 2025-09-21

246 downloads per month

MIT license

29KB
598 lines

parse-more

Parse-more is an extension of the Parse trait from the syn crate, allowing to parse input from procedural macros directly, without having to create a custom structure and implementing the Parse trait on it.

It provides classic syn macros and functions variant, using the ParseMore trait instead.

Example

use quote::quote;
use parse_more::{parse_more_macro_input, Concat, Braced};
use proc_macro::TokenStream;
use syn::{Expr, Ident, Token, punctuated::Punctuated};

#[proc_macro]
pub fn complex_args(input: TokenStream) -> TokenStream {
   let content = parse_more_macro_input!(
       input as Punctuated<Concat<(Ident, Token![=>], Braced<(Ident, Expr)>)>, Token![,]>
   );
   content
       .into_iter()
       .map(|concat| {
           // Second item is discarded (it's the => arrow)
           let (ident, _, Braced((other_ident, literal))) = concat.value();
           quote! {
            println!("{}: {} versus other type {}", #literal, (-1i8) as #ident, (-1i8) as #other_ident);
           }
       })
       .collect::<proc_macro2::TokenStream>()
       .into()
}

And then :

complex_args! {
    u8 => {
        (i8, "u8 integer")
    },
    u16 => {
        (i16, "u16 integer")
    },
    Foo => {
        (Bar, 8 + 42)
    }
}

Installation

Add to your Cargo.toml file:

[dependencies]
parse-more = "0.2"

Contribution

Contributions are welcome! Open an issue or a pull request.

License

This project is licensed under the MIT License.

Dependencies

~165–570KB
~14K SLoC