Make #[max]
an attribute in newtype_index
This commit is contained in:
parent
93429948cf
commit
91c3c2040c
4 changed files with 21 additions and 17 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue