-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add Required
system param
#2440
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
Conversation
Looks interesting. What do you see this being used for? |
Any situation where the local resource cannot be initialized automatically, and anytime say a plugin author wants to draw attention to a local resource being configurable. |
Looks pretty good, however, I'm not so sure about the name Or, would it be possible to overload the usage of Maybe like |
My preference is definitely to override or extend Local in some way; the usage of the two APIs is identical except at initialization. I suppose there's no way to default to this behaviour if FromWorld is missing? |
Specialization could probably make this work, but without it i'm pretty this is impossible if we want FromWorld to be "automatic" behavior. We could remove the FromWorld constraint and make Local always require manual configuration, but that would be a pretty huge step down in usability. |
Not a fan of having both But I would love to have something that fails to compile without a |
If we're going to have another type for this, I think Configured is the best name so far. It guides the user toward the "config()" api and semi-implies that if you don't "configure" it, something bad might happen. |
|
+1 to
I low-key assumed that was already the case when skimming it. Hm.
Not any more than |
Would it be possible to have a const generic to specify if the struct Local<const DEFAULT: bool>;
fn init<const DEFAULT: bool>(test: Local<DEFAULT>) {
if DEFAULT {
println!("using default");
} else {
println!("need configuration");
}
}
Didn't check, but it's an |
OK, so I just had a real-world use case for what this PR proposes. See: https://discord.com/channels/691052431525675048/742884593551802431/864264371106742312 |
I played with the const generic option in #2463, it works but I think it's not pretty in current Rust |
Closing because better patterns exist. |
# Objective - Fix the ugliness of the `config` api. - Supercedes bevyengine#2440, bevyengine#2463, bevyengine#2491 ## Solution - Since bevyengine#2398, capturing closure systems have worked. - Use those instead where we needed config before - Remove the rest of the config api. - Related: bevyengine#2777
Adds an alternative to Local without a FromWorld bound.