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 and FromReflect for AssetPath #8531

Merged
merged 5 commits into from
May 8, 2023

Conversation

minchopaskal
Copy link
Contributor

Objective

Solution

  • Straightforward derive of Reflect and FromReflect for AssetPath
  • Implement Reflect and FromReflect for Cow<'static, Path> as to satisfy the 'static lifetime requierments of bevy_reflect. Implementation is a direct copy of that for Cow<'static, str> so maybe it begs the question that was already asked in bevy_reflect: Support Cow<'static, [T]> #7429 - maybe it would be benefitial to write a general implementation for Reflect for Cow<'static, T>.

@github-actions
Copy link
Contributor

github-actions bot commented May 2, 2023

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added A-Assets Load files from disk to use for things like images, models, and sounds A-Reflection Runtime information about types C-Usability A simple quality-of-life change that makes Bevy easier to use labels May 2, 2023
@alice-i-cecile alice-i-cecile requested a review from MrGVSV May 2, 2023 15:13
@alice-i-cecile
Copy link
Member

I'm in favor of the general form TBH.

@MrGVSV
Copy link
Member

MrGVSV commented May 2, 2023

Not sure we could have a blanket impl like that. I think the main concern is that we lock ourselves into a single ReflectKind (besides possible issues with the blanket impl itself). It already wouldn't work since we want Cow<'static, str> to be a Value but we also want Cow<'static, [T]> to be a List.

Copy link
Member

@MrGVSV MrGVSV left a comment

Choose a reason for hiding this comment

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

Just a few comments.

Also, I agree that we could maybe reduce the code duplication (maybe a macro_rules for &'static T/Cow<'static, T>?), but that can be done in a separate PR.

crates/bevy_asset/src/path.rs Show resolved Hide resolved
crates/bevy_reflect/src/impls/std.rs Outdated Show resolved Hide resolved
crates/bevy_reflect/src/impls/std.rs Outdated Show resolved Hide resolved
crates/bevy_reflect/src/impls/std.rs Outdated Show resolved Hide resolved
crates/bevy_reflect/src/impls/std.rs Show resolved Hide resolved
Implement Reflect::debug for Cow<'static, Path>

Style fixes
Copy link
Member

@MrGVSV MrGVSV left a comment

Choose a reason for hiding this comment

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

Sorry two more comments I forgot to leave 😅

crates/bevy_reflect/src/impls/std.rs Show resolved Hide resolved
crates/bevy_asset/src/path.rs Show resolved Hide resolved
Copy link
Member

@MrGVSV MrGVSV left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for doing this!

@minchopaskal
Copy link
Contributor Author

My pleasure!

@alice-i-cecile
Copy link
Member

@minchopaskal can you please resolve comments that you've addressed to make things easier for further reviewers to follow?

@minchopaskal
Copy link
Contributor Author

@alice-i-cecile done. Sorry! I made the assumption that the one who leaves comments should resolve them.

@alice-i-cecile
Copy link
Member

Totally fine, it's just an arbitrary cultural choice we've made :)

@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 May 8, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue May 8, 2023
Merged via the queue into bevyengine:main with commit fe57b9f May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds 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.

Reflect for AssetPath
3 participants