Skip to content

Commit 643c990

Browse files
committed
Add warning to doc
1 parent 2ee3038 commit 643c990

File tree

1 file changed

+13
-0
lines changed
  • crates/bevy_reflect/bevy_reflect_derive/src

1 file changed

+13
-0
lines changed

crates/bevy_reflect/bevy_reflect_derive/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,24 @@ pub(crate) static TYPE_NAME_ATTRIBUTE_NAME: &str = "type_name";
157157
///
158158
/// This attribute excludes the field from the hash computation in `Reflect::reflect_hash`.
159159
///
160+
/// It's recommended that when using this attribute, the `#[reflect(skip_partial_eq)]` attribute also be used.
161+
/// This is to uphold the following [property]:
162+
/// ```text
163+
/// a.reflect_partial_eq(b) -> a.reflect_hash() == b.reflect_hash()
164+
/// ```
165+
///
160166
/// ## `#[reflect(skip_partial_eq)]`
161167
///
162168
/// This attribute excludes the field from comparison in `Reflect::reflect_partial_eq`.
163169
///
170+
/// It's recommended that when using this attribute, the `#[reflect(skip_hash)]` attribute also be used.
171+
/// This is to uphold the following [property]:
172+
/// ```text
173+
/// a.reflect_partial_eq(b) -> a.reflect_hash() == b.reflect_hash()
174+
/// ```
175+
///
164176
/// [`reflect_trait`]: macro@reflect_trait
177+
/// [property]: https://doc.rust-lang.org/std/hash/trait.Hash.html#hash-and-eq
165178
#[proc_macro_derive(Reflect, attributes(reflect, reflect_value, type_path, type_name))]
166179
pub fn derive_reflect(input: TokenStream) -> TokenStream {
167180
let ast = parse_macro_input!(input as DeriveInput);

0 commit comments

Comments
 (0)