-
-
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
[Merged by Bors] - Allow String
and &String
as Id
for AssetServer.get_handle(id)
#3280
Conversation
`AssetServer.get_handle(id)`
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 great, thanks!
Can't you already do this? let handle = asset_server.get_handle(&*format!("models/{}", name); |
Looks like you can do that, but why not make it easier? Especially for beginners. |
We could possibly do it for |
That's an even better idea. |
I can condense this |
I think avoiding blanket impls here is a good idea because of their potential to conflict with future impls we need. I'm happy with the solution implemented in this pr. |
bors r+ |
…#3280) # Objective Make it easier to build and use an asset path with `format!()`. This can be useful for accessing assets in a loop. Enabled by this PR: ```rust let monkey_handle = asset_server.get_handle(&format!("models/monkey/Monkey.gltf#Mesh0/Primitive0")); let monkey_handle = asset_server.get_handle(format!("models/monkey/Monkey.gltf#Mesh0/Primitive0")); ``` Before this PR: ```rust let monkey_handle = asset_server.get_handle(format!("models/monkey/Monkey.gltf#Mesh0/Primitive0").as_str()); ``` It's just a tiny improvement in ergonomics, but i ran into it and was wondering why the function does not accept a `String` and Bevy is all about simplicity/ergonomics, right? 😄😉 ## Solution Implement `Into<HandleId>` for `String` and `&String`.
String
and &String
as Id
for AssetServer.get_handle(id)
String
and &String
as Id
for AssetServer.get_handle(id)
Objective
Make it easier to build and use an asset path with
format!()
. This can be useful for accessing assets in a loop.Enabled by this PR:
Before this PR:
It's just a tiny improvement in ergonomics, but i ran into it and was wondering why the function does not accept a
String
and Bevy is all about simplicity/ergonomics, right? 😄😉Solution
Implement
Into<HandleId>
forString
and&String
.