@@ -47,11 +47,11 @@ pub enum ReflectMut<'a> {
47
47
48
48
/// A reflected Rust type.
49
49
///
50
- /// Methods for working with particular kinds of Rust type are available using the [`List `], [`Map `],
51
- /// [`Struct `], [`TupleStruct`], and [`Tuple `] subtraits.
50
+ /// Methods for working with particular kinds of Rust type are available using the [`Array `], [`List `],
51
+ /// [`Map `], [`Tuple`], [` TupleStruct`], [`Struct`], and [`Enum `] subtraits.
52
52
///
53
- /// When using `#[derive(Reflect)]` with a struct or tuple struct, the suitable subtrait for that
54
- /// type (`Struct` or `TupleStruct `) is derived automatically.
53
+ /// When using `#[derive(Reflect)]` on a struct, tuple struct or enum , the suitable subtrait for that
54
+ /// type (`Struct`, `TupleStruct` or `Enum `) is derived automatically.
55
55
pub trait Reflect : Any + Send + Sync {
56
56
/// Returns the [type name][std::any::type_name] of the underlying type.
57
57
fn type_name ( & self ) -> & str ;
@@ -91,8 +91,12 @@ pub trait Reflect: Any + Send + Sync {
91
91
/// - If `T` is a [`TupleStruct`] or [`Tuple`], then the value of each
92
92
/// numbered field is applied to the corresponding numbered field of
93
93
/// `self.` Fields which are not present in both values are ignored.
94
- /// - If `T` is a [`List`], then each element of `value` is applied to the
95
- /// corresponding element of `self`. Up to `self.len()` items are applied,
94
+ /// - If `T` is an [`Enum`], then the variant of `self` is `updated` to match
95
+ /// the variant of `value`. The corresponding fields of that variant are
96
+ /// applied from `value` onto `self`. Fields which are not present in both
97
+ /// values are ignored.
98
+ /// - If `T` is a [`List`] or [`Array`], then each element of `value` is applied
99
+ /// to the corresponding element of `self`. Up to `self.len()` items are applied,
96
100
/// and excess elements in `value` are appended to `self`.
97
101
/// - If `T` is a [`Map`], then for each key in `value`, the associated
98
102
/// value is applied to the value associated with the same key in `self`.
@@ -102,7 +106,7 @@ pub trait Reflect: Any + Send + Sync {
102
106
///
103
107
/// Note that `Reflect` must be implemented manually for [`List`]s and
104
108
/// [`Map`]s in order to achieve the correct semantics, as derived
105
- /// implementations will have the semantics for [`Struct`], [`TupleStruct`]
109
+ /// implementations will have the semantics for [`Struct`], [`TupleStruct`], [`Enum`]
106
110
/// or none of the above depending on the kind of type. For lists and maps, use the
107
111
/// [`list_apply`] and [`map_apply`] helper functions when implementing this method.
108
112
///
@@ -137,11 +141,11 @@ pub trait Reflect: Any + Send + Sync {
137
141
138
142
/// Clones the value as a `Reflect` trait object.
139
143
///
140
- /// When deriving `Reflect` for a struct or struct tuple , the value is
141
- /// cloned via [`Struct::clone_dynamic`] (resp.
142
- /// [`TupleStruct ::clone_dynamic`]). Implementors of other `Reflect`
143
- /// subtraits (e.g. [`List`], [`Map`]) should use those subtraits'
144
- /// respective `clone_dynamic` methods.
144
+ /// When deriving `Reflect` for a struct, tuple struct or enum , the value is
145
+ /// cloned via [`Struct::clone_dynamic`], [`TupleStruct::clone_dynamic`],
146
+ /// or [`Enum ::clone_dynamic`], respectively.
147
+ /// Implementors of other `Reflect` subtraits (e.g. [`List`], [`Map`]) should
148
+ /// use those subtraits' respective `clone_dynamic` methods.
145
149
fn clone_value ( & self ) -> Box < dyn Reflect > ;
146
150
147
151
/// Returns a hash of the value (which includes the type).
0 commit comments