Make #[max] an attribute in newtype_index
This commit is contained in:
@@ -59,6 +59,17 @@ impl Parse for Newtype {
|
||||
ord = false;
|
||||
false
|
||||
}
|
||||
"max" => {
|
||||
let Ok(Meta::NameValue(literal) )= attr.parse_meta() else {
|
||||
panic!("#[max = NUMBER] attribute requires max value");
|
||||
};
|
||||
|
||||
if let Some(old) = max.replace(literal.lit) {
|
||||
panic!("Specified multiple MAX: {:?}", old);
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
_ => true,
|
||||
},
|
||||
_ => true,
|
||||
@@ -84,16 +95,6 @@ impl Parse for Newtype {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if body.lookahead1().peek(kw::MAX) {
|
||||
body.parse::<kw::MAX>()?;
|
||||
body.parse::<Token![=]>()?;
|
||||
let val: Lit = body.parse()?;
|
||||
try_comma()?;
|
||||
if let Some(old) = max.replace(val) {
|
||||
panic!("Specified multiple MAX: {:?}", old);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// We've parsed everything that the user provided, so we're done
|
||||
if body.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user