Skip to content

Commit beafdbb

Browse files
damyanpknickish
authored andcommitted
Fix enum attribute parsing - allows exposing enum diff stucts
1 parent bef7880 commit beafdbb

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

derive/src/parse.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,8 @@ pub fn parse_data(input: TokenStream) -> Data {
15741574
res = Data::Struct(struct_);
15751575
}
15761576
"enum" => {
1577-
let enum_ = next_enum(&mut source);
1577+
let mut enum_ = next_enum(&mut source);
1578+
enum_.attributes = attributes;
15781579
res = Data::Enum(enum_);
15791580
}
15801581
"union" => unimplemented!("Unions are not supported"),

tests/expose.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,22 @@ fn test_expose_rename() {
7070
}
7171
}
7272
}
73+
74+
#[test]
75+
fn test_expose_enum() {
76+
#[derive(Debug, Clone, PartialEq, Difference)]
77+
#[difference(expose)]
78+
pub enum Test {
79+
A,
80+
B(u32),
81+
}
82+
83+
let first = Test::A;
84+
let second = Test::B(1);
85+
86+
for diff in first.diff(&second) {
87+
match diff {
88+
TestStructDiffEnum::Replace(_) => {}
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)