Skip to content

Commit

Permalink
Implement Parse for CapturedParam
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 20, 2024
1 parent fc22fce commit c25900d
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 c25900d

Please sign in to comment.