Skip to content

Commit f7b1fcb

Browse files
committed
syn: add FieldKind type to data mod
1 parent c5c0b9b commit f7b1fcb

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

syn/src/data.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,22 @@ pub enum Fields {
4848
Unnamed(Items<Field>),
4949
}
5050

51+
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
52+
pub enum FieldKind {
53+
Named,
54+
Unnamed,
55+
}
56+
5157
impl Fields {
5258
pub fn is_unit(&self) -> bool { matches!(self, Fields::Unit) }
59+
60+
pub fn kind(&self) -> FieldKind {
61+
match self {
62+
Fields::Unit => FieldKind::Unnamed,
63+
Fields::Named(_) => FieldKind::Named,
64+
Fields::Unnamed(_) => FieldKind::Unnamed,
65+
}
66+
}
5367
}
5468

5569
pub trait Element: Sized {

syn/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ mod data;
5151
pub use attr::{Attr, ExtractAttr, ParametrizedAttr, SingularAttr};
5252
pub use cls::{LiteralClass, TypeClass, ValueClass};
5353
pub use data::{
54-
DataInner, DataType, DeriveInner, Element, Field, Fields, Items, NamedField, Scope, Variant,
55-
Vis,
54+
DataInner, DataType, DeriveInner, Element, Field, FieldKind, Fields, Items, NamedField, Scope,
55+
Variant, Vis,
5656
};
5757
pub use error::Error;
5858
pub use parsers::{MetaArg, MetaArgList, MetaArgNameValue};

0 commit comments

Comments
 (0)