diff --git a/src/lib.rs b/src/lib.rs index 1d1616d..b0799ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -240,7 +240,7 @@ impl Parse for TestHelper { .parse() .map_err(|err| Error::new(err.span(), "expected helper function"))?; let static_args = input.peek(Paren).then(|| input.parse()).transpose()?; - let static_return_type = ReturnType::try_parse(input).transpose()?; + let static_return_type = input.call(ReturnType::try_parse)?; let farrow = input.parse::]>()?; let cases; let braces = braced!(cases in input); @@ -405,7 +405,7 @@ impl Parse for CaseArgs { } let args = inner.parse()?; - let return_type = ReturnType::try_parse(&inner).transpose()?; + let return_type = inner.call(ReturnType::try_parse)?; let out = CaseArgs { braces, @@ -444,8 +444,9 @@ impl Parse for FnArgs { // Using `punctuated::parse_separated_nonempty` in this case, // because if this type is being parsed, arguments should be expected, // and trailing commas look sloppy... - let args = Punctuated::parse_separated_nonempty(&inner) - .map_err(|err| Error::new(err.span(), "missing function arguments"))?; + let args = inner + .call(Punctuated::parse_separated_nonempty) + .map_err(|err| Error::new(err.span(), "expected function arguments"))?; Ok(Self { parens, args }) } @@ -469,8 +470,8 @@ impl ReturnType { /// Conditionally parses the type, if a right-arrow is peeked from the stream. /// /// Included, due to the optional nature of return types in this macro. - fn try_parse(input: ParseStream) -> Option> { - input.peek(Token![->]).then(|| input.parse()) + fn try_parse(input: ParseStream) -> Result> { + input.peek(Token![->]).then(|| input.parse()).transpose() } }