Skip to content

Commit e011ba7

Browse files
authored
Merge pull request #1758 from dtolnay/precisecapture
Implement Parse for CapturedParam
2 parents fc22fce + c25900d commit e011ba7

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/generics.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,10 +1046,8 @@ pub(crate) mod parsing {
10461046
let mut params = Punctuated::new();
10471047
loop {
10481048
let lookahead = input.lookahead1();
1049-
params.push_value(if lookahead.peek(Lifetime) {
1050-
input.parse().map(CapturedParam::Lifetime)?
1051-
} else if lookahead.peek(Ident) {
1052-
input.parse().map(CapturedParam::Ident)?
1049+
params.push_value(if lookahead.peek(Lifetime) || lookahead.peek(Ident) {
1050+
input.parse::<CapturedParam>()?
10531051
} else if lookahead.peek(Token![>]) {
10541052
break;
10551053
} else {
@@ -1073,6 +1071,21 @@ pub(crate) mod parsing {
10731071
})
10741072
}
10751073
}
1074+
1075+
#[cfg(feature = "full")]
1076+
#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
1077+
impl Parse for CapturedParam {
1078+
fn parse(input: ParseStream) -> Result<Self> {
1079+
let lookahead = input.lookahead1();
1080+
if lookahead.peek(Lifetime) {
1081+
input.parse().map(CapturedParam::Lifetime)
1082+
} else if lookahead.peek(Ident) {
1083+
input.parse().map(CapturedParam::Ident)
1084+
} else {
1085+
Err(lookahead.error())
1086+
}
1087+
}
1088+
}
10761089
}
10771090

10781091
#[cfg(feature = "printing")]

0 commit comments

Comments
 (0)