Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reflect for BinaryHeap #12503

Merged
merged 3 commits into from
Mar 17, 2024

Conversation

cBournhonesque
Copy link
Contributor

@cBournhonesque cBournhonesque commented Mar 16, 2024

Objective

I wanted to have reflection for BinaryHeap for a personal project.

I'm running into some issues:

  • I wanted to represent BinaryHeap as a reflect::List type since it's essentially a wrapper around a Vec, however there's no public way to access the underlying Vec, which makes it hard to implement the reflect::List methods. I have omitted the reflect::List methods for now.. I'm not sure if that's a blocker?
  • what would be the alternatives? Simply not implement reflect::List? It is possible to implement FromReflect without it. Would the type be Struct then?

@james7132 james7132 added C-Usability A simple quality-of-life change that makes Bevy easier to use A-Reflection Runtime information about types labels Mar 16, 2024
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Bit of a shame not to have the list-like behavior fully reflected, but it's fine to do this incrementally.

Copy link
Member

@james7132 james7132 left a comment

Choose a reason for hiding this comment

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

Please fix CI, there's a few errors and likely formatting that needs to be addressed.

@cBournhonesque
Copy link
Contributor Author

I think it was erroring because I was still representing BinaryHeap as ReflectKind::List even though I could not implement reflect::List.

I switched it to just use ReflectKind::Value.

Although I'm not too sure how it works to add other bounds? I couldn't figure out how to add reflect(Debug, Serialize, Deserialize)

@MrGVSV
Copy link
Member

MrGVSV commented Mar 17, 2024

Although I'm not too sure how it works to add other bounds? I couldn't figure out how to add reflect(Debug, Serialize, Deserialize)

Those can only be applied if you require that T also implements those traits. I don't think we'd want to be that restrictive, though.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Mar 17, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 17, 2024
Merged via the queue into bevyengine:main with commit ea6540d Mar 17, 2024
27 checks passed
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 C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants