macro: named struct: allow short form for fields
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
c54afe1be4
commit
183125b1cd
@ -539,10 +539,20 @@ fn handle_named_struct_fields(
|
|||||||
.remove(&name_str)
|
.remove(&name_str)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
c_format_err!(name.span(), "missing field in definition: '{}'", name_str)
|
c_format_err!(name.span(), "missing field in definition: '{}'", name_str)
|
||||||
})?
|
})?;
|
||||||
.expect_object()?;
|
|
||||||
|
let def = match def {
|
||||||
|
Expression::Expr(syn::Expr::Lit(lit)) => match lit.lit {
|
||||||
|
syn::Lit::Str(description) => ParameterDefinition::builder()
|
||||||
|
.description(Some(description))
|
||||||
|
.build()
|
||||||
|
.unwrap(),
|
||||||
|
other => c_bail!(other.span(), "expected description as literal string"),
|
||||||
|
},
|
||||||
|
Expression::Object(obj) => ParameterDefinition::from_object(obj)?,
|
||||||
|
other => c_bail!(other.span(), "expected description or field definition"),
|
||||||
|
};
|
||||||
|
|
||||||
let def = ParameterDefinition::from_object(def)?;
|
|
||||||
def.add_verifiers(&name_str, this, &mut verify_entries);
|
def.add_verifiers(&name_str, this, &mut verify_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user