Skip to content

Commit

Permalink
Merge pull request #1758 from dtolnay/precisecapture
Browse files Browse the repository at this point in the history
Implement Parse for CapturedParam
  • Loading branch information
dtolnay authored Oct 20, 2024
2 parents fc22fce + c25900d commit e011ba7
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CapturedParam>()?
} else if lookahead.peek(Token![>]) {
break;
} else {
Expand All @@ -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<Self> {
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")]
Expand Down

0 comments on commit e011ba7

Please sign in to comment.