xso: implement exhaustive enums
These more closely mirror how enums work currently with the macros. Non-exhaustive enums may be useful though and kind of were the natural thing to implement.
This commit is contained in:
parent
a20caf839f
commit
c028c3b91a
6 changed files with 127 additions and 2 deletions
|
|
@ -12,7 +12,7 @@ use syn::*;
|
|||
|
||||
use crate::common::{AsXmlParts, FromXmlParts, ItemDef};
|
||||
use crate::compound::Compound;
|
||||
use crate::meta::{NameRef, NamespaceRef, XmlCompoundMeta};
|
||||
use crate::meta::{reject_key, Flag, NameRef, NamespaceRef, XmlCompoundMeta};
|
||||
|
||||
/// Definition of a struct and how to parse it.
|
||||
pub(crate) struct StructDef {
|
||||
|
|
@ -48,11 +48,14 @@ impl StructDef {
|
|||
span: meta_span,
|
||||
namespace,
|
||||
name,
|
||||
exhaustive,
|
||||
debug,
|
||||
builder,
|
||||
iterator,
|
||||
} = meta;
|
||||
|
||||
reject_key!(exhaustive flag not on "structs" only on "enums");
|
||||
|
||||
let Some(namespace) = namespace else {
|
||||
return Err(Error::new(meta_span, "`namespace` is required on structs"));
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue