let lt_token: Token![<] = input.parse()?;
let mut params = Punctuated::new();
- let mut has_type_param = false;
+ let mut allow_lifetime_param = true;
+ let mut allow_type_param = true;
loop {
if input.peek(Token![>]) {
break;
let attrs = input.call(Attribute::parse_outer)?;
let lookahead = input.lookahead1();
- if !has_type_param && lookahead.peek(Lifetime) {
+ if allow_lifetime_param && lookahead.peek(Lifetime) {
params.push_value(GenericParam::Lifetime(LifetimeDef {
attrs: attrs,
..input.parse()?
}));
- } else if lookahead.peek(Ident) {
- has_type_param = true;
+ } else if allow_type_param && lookahead.peek(Ident) {
+ allow_lifetime_param = false;
params.push_value(GenericParam::Type(TypeParam {
attrs: attrs,
..input.parse()?
}));
+ } else if lookahead.peek(Token![const]) {
+ allow_lifetime_param = false;
+ allow_type_param = false;
+ params.push_value(GenericParam::Const(ConstParam {
+ attrs: attrs,
+ ..input.parse()?
+ }));
} else {
return Err(lookahead.error());
}