[Merged by Bors] - Rename Handle::as_weak() to cast_weak()#5321
Closed
manokara wants to merge 1 commit intobevyengine:mainfrom
Closed
[Merged by Bors] - Rename Handle::as_weak() to cast_weak()#5321manokara wants to merge 1 commit intobevyengine:mainfrom
manokara wants to merge 1 commit intobevyengine:mainfrom
Conversation
alice-i-cecile
approved these changes
Jul 15, 2022
alice-i-cecile
approved these changes
Jul 15, 2022
Member
|
I really don't like the name |
Contributor
|
I don’t really understand this code so I don’t think I’m qualified to review it. |
james7132
approved these changes
Oct 28, 2022
Member
james7132
left a comment
There was a problem hiding this comment.
I still think this API is a bad code smell. We should try to get rid of it's primary uses and migrate to a better alternative.
For now, this is a good solution to prevent further misuse. The code looks good to me.
Member
|
bors r+ |
bors bot
pushed a commit
that referenced
this pull request
Oct 28, 2022
# Objective Following discussion on #3536 and #3522, `Handle::as_weak()` takes a type `U`, reinterpreting the handle as of another asset type while keeping the same ID. This is mainly used today in font atlas code. This PR does two things: - Rename the method to `cast_weak()` to make its intent more clear - Actually change the type uuid in the handle if it's not an asset path variant. ## Migration Guide - Rename `Handle::as_weak` uses to `Handle::cast_weak` The method now properly sets the associated type uuid if the handle is a direct reference (e.g. not a reference to an `AssetPath`), so adjust you code accordingly if you relied on the previous behavior.
Contributor
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this pull request
Feb 1, 2023
# Objective Following discussion on bevyengine#3536 and bevyengine#3522, `Handle::as_weak()` takes a type `U`, reinterpreting the handle as of another asset type while keeping the same ID. This is mainly used today in font atlas code. This PR does two things: - Rename the method to `cast_weak()` to make its intent more clear - Actually change the type uuid in the handle if it's not an asset path variant. ## Migration Guide - Rename `Handle::as_weak` uses to `Handle::cast_weak` The method now properly sets the associated type uuid if the handle is a direct reference (e.g. not a reference to an `AssetPath`), so adjust you code accordingly if you relied on the previous behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Following discussion on #3536 and #3522,
Handle::as_weak()takes a typeU, reinterpreting the handle as of another asset type while keeping the same ID. This is mainly used today in font atlas code. This PR does two things:cast_weak()to make its intent more clearMigration Guide
Rename
Handle::as_weakuses toHandle::cast_weakThe method now properly sets the associated type uuid if the handle is a direct reference (e.g. not a reference to an
AssetPath), so adjust you code accordingly if you relied on the previous behavior.