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

Change From<Handle<A>> for AssetId<A> implementations to implement Borrow<Handle<A>> instead #10372

Closed
wants to merge 3 commits into from

Conversation

doonv
Copy link
Contributor

@doonv doonv commented Nov 4, 2023

Objective

In my project I used to do images.get_mut(mutable_reference_to_handle), but that no longer works in 0.12.0 because From<&mut Handle<A>> isn't implemented for AssetId<A>. This PR fixes that.

Solution

Replace the implementations:

  • From<Handle<A>> for AssetId<A>
  • From<&Handle<A>> for AssetId<A>

With: impl<T: Borrow<Handle<A>>, A: Asset> From<T> for AssetId<A>

Result: You can now pass mutable references to handles to functions that require AssetIds

Changelog

  • Added ability to pass mutable references to Handles as AssetIds

@alice-i-cecile alice-i-cecile added A-Assets Load files from disk to use for things like images, models, and sounds C-Usability A simple quality-of-life change that makes Bevy easier to use labels Nov 4, 2023
@doonv doonv changed the title Implement From<&mut Handle<A>> for AssetId<A> Change From<Handle<A>> for AssetId<A> implementations to implement Borrow<Handle<A>> instead Nov 5, 2023
@doonv
Copy link
Contributor Author

doonv commented Nov 24, 2023

It appears #10628 has already solved this problem. So I'm closing the PR.

@doonv doonv closed this Nov 24, 2023
@doonv doonv deleted the impl-handle-mut-ref branch January 21, 2024 13:33
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 C-Usability A simple quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants