From c25900d5f4949fb04890f8507d9b1dd5be18de5a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 19 Oct 2024 22:54:10 -0700 Subject: [PATCH] Implement Parse for CapturedParam --- src/generics.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/generics.rs b/src/generics.rs index f1555228d..746184826 100644 --- a/src/generics.rs +++ b/src/generics.rs @@ -1046,10 +1046,8 @@ pub(crate) mod parsing { let mut params = Punctuated::new(); loop { let lookahead = input.lookahead1(); - params.push_value(if lookahead.peek(Lifetime) { - input.parse().map(CapturedParam::Lifetime)? - } else if lookahead.peek(Ident) { - input.parse().map(CapturedParam::Ident)? + params.push_value(if lookahead.peek(Lifetime) || lookahead.peek(Ident) { + input.parse::()? } else if lookahead.peek(Token![>]) { break; } else { @@ -1073,6 +1071,21 @@ pub(crate) mod parsing { }) } } + + #[cfg(feature = "full")] + #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))] + impl Parse for CapturedParam { + fn parse(input: ParseStream) -> Result { + let lookahead = input.lookahead1(); + if lookahead.peek(Lifetime) { + input.parse().map(CapturedParam::Lifetime) + } else if lookahead.peek(Ident) { + input.parse().map(CapturedParam::Ident) + } else { + Err(lookahead.error()) + } + } + } } #[cfg(feature = "printing")]