call2-for-syn 1.0.0-preview-2

Apply parser functions to proc-macro2 token streams
Documentation

call2-for-syn

Latest Version docs.rs

This library provides a call2 function that sits somewhere in-between syn's parse2 and ParseBuffer::call: It lets you conveniently apply a parser function to a proc-macro2 token stream, for example from a quote!.

Example

use {
    call2_for_syn::call2,
    quote::quote,
    syn::{Ident, Token},
};

let (hello, world) = call2::<syn::Result<_>, _>(
    quote!(Hello world!),
    |input| {
        let hello: Ident = input.parse()?;
        let world: Ident = input.parse()?;
        input.parse::<Token![!]>()?;
        Ok((hello, world))
    },
)?;
assert_eq!(format!("{}", hello), "Hello");
assert_eq!(format!("{}", world), "world");