-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Make SavedAsset::get_labeled accept &str as label #11612
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
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.
Looks reasonable, thanks for doing such a good job motivating the changes.
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
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.
CowArc
has got to be my favorite rust-ism. LGTM pending borrow trait bound.
I reverted back to iterating over &str, and used the new trait bound in get_untyped_handle. I also switched get_erased_labeled and get_labeled to use the new form as well. I believe this is no longer a breaking change, so I removed the migration guide. |
Remember to update your PR description with the final changes: the "Solution" section is out-of-date. |
Thanks! |
# Objective - SavedAsset's iter_labels returns ```&str```, however accessing LabeledAssets requires ```CowArc<'static, str>``` - Although SavedAsset holds UntypedHandles in its hashmap of LabeledAssets, they are inaccessible as LabeledAssets are casted to SavedAsset or ErasedLoadedAsset, which don't contain their UntypedHandles - Adresses bevyengine#11609 ## Solution - Used Trait bounds to allow for either ```CowArc<'static, str>``` or ```&str``` to be used as a label in get_labeled and get_erased_labeled. - Added method get_untyped_handle to get UntypedHandle from the LabeledAsset. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Objective
&str
, however accessing LabeledAssets requiresCowArc<'static, str>
Solution
CowArc<'static, str>
or&str
to be used as a label in get_labeled and get_erased_labeled.