Skip to content

Conversation

@molikto
Copy link
Contributor

@molikto molikto commented Jan 9, 2026

Objective

be able to compare ordering of two dyn PartialReflect values

Solution.

add #[reflect(PartialOrd)] and method PartialReflect::reflect_partial_cmp.

(No structural comparsion following derive(PartialOrd) is implemented though).

Testing

Unit tests are added.

@kfc35 kfc35 added A-Reflection Runtime information about types S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Jan 10, 2026
Copy link
Contributor

@kfc35 kfc35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the tests 🙏 I don’t see anything obviously wrong with what is written as someone who is new to reading bevy reflect code. Seems to follow the patterns of the other traits appropriately.

(No structural comparsion following derive(PartialOrd) is implemented though).

I wonder if this is worth making an issue for implementing if we go forward with merging this

/// A custom implementation may be provided using `#[reflect(PartialEq(my_partial_eq_func))]` where
/// `my_partial_eq_func` is the path to a function matching the signature:
/// `(&Self, value: &dyn #bevy_reflect_path::Reflect) -> bool`.
/// * `#[reflect(PartialOrd)]` will let the implementation of `PartialReflect::reflect_partial_cmp`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I’m understanding what you wrote correctly, and just to conform with what’s written for the other #[reflect(...)] comments:

Suggested change
/// * `#[reflect(PartialOrd)]` will let the implementation of `PartialReflect::reflect_partial_cmp`
/// * `#[reflect(PartialOrd)]` will force the implementation of `PartialReflect::reflect_partial_cmp`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Reflection Runtime information about types D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants