-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Replace FromWorld blanket implementation with derive macro #4265
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
Comments
Implicit FromWorld impls for Default impls means that we can use both traits in things like Right now thinking about FromWorld as "Default but for things that need World access" seems to be working reasonably well. Use Default generally, unless you need world access. Then implement FromWorld instead. If you can implement Default, by definition you don't need FromWorld. What is the specific use case you're trying to enable? |
As a more scoped workaround:
I would also like to hear a bit more about the use cases before pursuing that though. |
Thanks for the replies!
Sometimes I need to have |
The workaround doesn't seem too bad: I'm reluctant to degrade the common-case UX for this. Would my solution with split methods work for you? |
Yes, it's much better then I suggested. And I like its explicitness: |
Agreed: I think its explicitness is quite good, and from a UX perspective I would say that's probably a wash when weighed against adding yet another set of methods. I think overall I'd personally be happy enough to see a PR with that change (although in the long-run this feels like yet another "plugins should be structured" problem). |
Idk if I want to add another dimension to the "resource setup" category of things:
(with impls on both World and App) Thats a pretty big set of apis for users to sort through. And it means that if we need to add another variant in the future, this set of apis will "balloon out of control". |
Yep, same problem as #1978. Unfortunately I don't really see a good way to apply the pattern used there here :/ |
Got it, probably there is no good solution. I will move my resource initialization into "plugin" as a workaround then. |
What problem does this solve or what need does it fill?
Currently resources can have either
FromWorld
orDefault
trait implementation because of blankedFromWorld
implementation. This causes inconveniences with other crates integration. For example, confy crate requires configuration structure to haveDefault
trait, so I can't create a convenientFromWorld
for it.What solution would you like?
I would suggest to switch to explicit derive macro.
The text was updated successfully, but these errors were encountered: