[−][src]Function call2_for_syn::call2_strict
pub fn call2_strict<T, P: FnOnce(ParseStream<'_>) -> T>(
input: TokenStream,
parser: P
) -> stdResult<T, Incomplete<T>>
Analogous to syn::parse2
and syn::parse::ParseBuffer::call
.
Errors
Iff not all of input
is consumed by parser
.
parser
's result is still returned in the error value, in this case.
Examples
use call2_for_syn::call2_strict; use quote::quote; use syn::{Ident, Token}; let (hello, world) = call2_strict(quote!(Hello world!), |input| { let hello: Ident = input.parse()?; let world: Ident = input.parse()?; // input.parse::<Token![!]>()?; syn::Result::Ok((hello, world)) }).unwrap_err().parsed?; assert_eq!(format!("{}", hello), "Hello"); assert_eq!(format!("{}", world), "world");
use call2_for_syn::call2_strict; use quote::quote; use syn::{Ident, Token}; let (hello, world) = call2_strict(quote!(Hello world!), |input| { let hello: Ident = input.parse()?; let world: Ident = input.parse()?; input.parse::<Token![!]>()?; syn::Result::Ok((hello, world)) })??; assert_eq!(format!("{}", hello), "Hello"); assert_eq!(format!("{}", world), "world");