-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Merged by Bors] - bevy_reflect: Added get_boxed
method to reflect_trait
#4120
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks good, and this is clear and useful functionality. I would really like docs on this (and get_func and get_mut_funct), but I'm not immediately sure where they should go. Sticking them on the macro is waaay deep in the internals, and sticking them on the generated code is a bit odd.
I think that I would like it on both: it looks like we're generating a ReflectFoo
type when this is used, and that should have proper docs.
Could you please add:
- basic docs to reflect_trait function.
- generated doc strings for the generated trait
- generated doc strings for the methods
Haha I was actually going to ask about this. I think it makes sense to put them in the generated code. In that case it shows up in intellisense and other editor tools. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! It's nice to slowly document reflection too :)
get_boxed
method to reflect_trait
get_boxed
method to reflect_trait
Co-authored-by: Alice Cecile <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
bors r+ |
# Objective Allow `Box<dyn Reflect>` to be converted into a `Box<dyn MyTrait>` using the `#[reflect_trait]` macro. The other methods `get` and `get_mut` only provide a reference to the reflected object. ## Solution Add a `get_boxed` method to the `Reflect***` struct generated by the `#[reflect_trait]` macro. This method takes in a `Box<dyn Reflect>` and returns a `Box<dyn MyTrait>`. Co-authored-by: MrGVSV <[email protected]>
get_boxed
method to reflect_trait
get_boxed
method to reflect_trait
…#4120) # Objective Allow `Box<dyn Reflect>` to be converted into a `Box<dyn MyTrait>` using the `#[reflect_trait]` macro. The other methods `get` and `get_mut` only provide a reference to the reflected object. ## Solution Add a `get_boxed` method to the `Reflect***` struct generated by the `#[reflect_trait]` macro. This method takes in a `Box<dyn Reflect>` and returns a `Box<dyn MyTrait>`. Co-authored-by: MrGVSV <[email protected]>
…#4120) # Objective Allow `Box<dyn Reflect>` to be converted into a `Box<dyn MyTrait>` using the `#[reflect_trait]` macro. The other methods `get` and `get_mut` only provide a reference to the reflected object. ## Solution Add a `get_boxed` method to the `Reflect***` struct generated by the `#[reflect_trait]` macro. This method takes in a `Box<dyn Reflect>` and returns a `Box<dyn MyTrait>`. Co-authored-by: MrGVSV <[email protected]>
Objective
Allow
Box<dyn Reflect>
to be converted into aBox<dyn MyTrait>
using the#[reflect_trait]
macro. The other methodsget
andget_mut
only provide a reference to the reflected object.Solution
Add a
get_boxed
method to theReflect***
struct generated by the#[reflect_trait]
macro. This method takes in aBox<dyn Reflect>
and returns aBox<dyn MyTrait>
.