@@ -24,32 +24,43 @@ pub struct A {
24
24
z : HashMap < String , f32 > ,
25
25
}
26
26
27
- /// Deriving reflect on a unit struct will implement `Reflect` and `Struct` traits
27
+ /// Deriving reflect on a unit struct will implement the `Reflect` and `Struct` traits
28
28
#[ derive( Reflect ) ]
29
29
pub struct B ;
30
30
31
- /// Deriving reflect on a tuple struct will implement `Reflect` and `TupleStruct` traits
31
+ /// Deriving reflect on a tuple struct will implement the `Reflect` and `TupleStruct` traits
32
32
#[ derive( Reflect ) ]
33
33
pub struct C ( usize ) ;
34
34
35
+ /// Deriving reflect on an enum will implement the `Reflect` and `Enum` traits
36
+ #[ derive( Reflect ) ]
37
+ pub enum D {
38
+ A ,
39
+ B ( usize ) ,
40
+ C {
41
+ foo : f32 ,
42
+ bar : bool
43
+ }
44
+ }
45
+
35
46
/// Reflect has "built in" support for some common traits like `PartialEq`, `Hash`, and `Serialize`.
36
- /// These are exposed via methods like `Reflect::hash ()`, `Reflect::partial_eq ()`, and
37
- /// `Reflect::serialize ()`. You can force these implementations to use the actual trait
47
+ /// These are exposed via methods like `Reflect::reflect_hash ()`, `Reflect::reflect_partial_eq ()`, and
48
+ /// `Reflect::serializable ()`. You can force these implementations to use the actual trait
38
49
/// implementations (instead of their defaults) like this:
39
50
#[ derive( Reflect , Hash , Serialize , PartialEq ) ]
40
51
#[ reflect( Hash , Serialize , PartialEq ) ]
41
- pub struct D {
52
+ pub struct E {
42
53
x : usize ,
43
54
}
44
55
45
- /// By default, deriving with Reflect assumes the type is a "struct". You can tell reflect to treat
46
- /// your type as a "value type" by using the `reflect_value` attribute instead of `reflect`. It is
47
- /// generally a good idea to implement (and reflect) the `PartialEq`, `Serialize`, and `Deserialize`
48
- /// traits on `reflect_value` types to ensure that these values behave as expected when nested
49
- /// underneath Reflect-ed structs.
56
+ /// By default, deriving with Reflect assumes the type is either a "struct" or an "enum".
57
+ /// You can tell reflect to treat your type instead as a "value type" by using the `reflect_value`
58
+ /// attribute in place of `reflect`. It is generally a good idea to implement (and reflect)
59
+ /// the `PartialEq`, `Serialize`, and `Deserialize` traits on `reflect_value` types to ensure
60
+ /// that these values behave as expected when nested underneath Reflect-ed structs.
50
61
#[ derive( Reflect , Copy , Clone , PartialEq , Serialize , Deserialize ) ]
51
62
#[ reflect_value( PartialEq , Serialize , Deserialize ) ]
52
- pub enum E {
63
+ pub enum F {
53
64
X ,
54
65
Y ,
55
66
}
@@ -83,7 +94,7 @@ fn setup() {
83
94
// arity 12 or less.
84
95
ReflectRef :: Tuple ( _) => { }
85
96
// `Enum` is a trait automatically implemented for enums that derive Reflect. This trait allows you
86
- // to interact list possible variants and interact with the currently active one
97
+ // to interact with the current variant and its fields (if it has any)
87
98
ReflectRef :: Enum ( _) => { }
88
99
// `List` is a special trait that can be manually implemented (instead of deriving Reflect).
89
100
// This exposes "list" operations on your type, such as insertion. `List` is automatically
0 commit comments