-
-
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] - make sub_app
return an &App
and add sub_app_mut() -> &mut App
#3309
[Merged by Bors] - make sub_app
return an &App
and add sub_app_mut() -> &mut App
#3309
Conversation
ci failed to download rust |
bors try |
bors r+ |
Merge conflict. |
I chose to go against the grain with this api because the mutable variant will be waaaaay more common than the immutable one (as in 99.999% of the time people want a mutable reference). Immutable access is an exception to the rule. I personally think its worth giving the terser / more ergonomic |
For what it's worth, I thought the old name was confusing. I was looking for something that ended with |
Going against convention is a much greater affront to ergonomics than having to type 4 extra symbols (or less, if code completion is in a good mood). |
I still think something this central deserves a first class name. Immutable access to sub apps is pretty far off the happy path. With a few very exceptional cases, users shouldn't need to think about mutability at all here. Adding Not putting my foot down here though. Feel free to weigh in / gather support for your preferred approach. Imo this is a pretty clear case of what an exception to the convention should look like (if we are going to allow exceptions). Its worth discussing it as a community and trying to establish consensus so we can quickly resolve these disagreements in the future. If this isn't an exception to the convention, I don't think anything is. Vote here: (This is an "advisory vote" ... the results won't actually determine what we do, but I will give them weight) |
I think we should follow convention as much as we can. I know it's not a rule, and that there are bound to be exceptions that make sense, but this doesn't feel like one. I don't like the idea of having people learn Rust using libraries and small frameworks (most of which follow convention), then come to Bevy and find that the norms they've gotten used to don't apply. |
That example isn't really representative of what's happening here though. Accessors in Rust almost always follow the Or use |
I don't think the esthetics are worth breaking convention in this case. I definitely respect the argument, but as someone who relies on code completion or often times just guessing by following convention, this would trip me up without any perceived gain. It's also nice to see mutability at a glance when reading someone else's code. I'm not good enough to infer it or remember these exceptions. 🙂 |
6ce78df
to
8b79d64
Compare
8b79d64
to
53c151f
Compare
Alrighty there is overwhelming support for |
bors r+ |
Build failed (retrying...): |
Build failed: |
bors r+ |
Pull request successfully merged into main. Build succeeded: |
sub_app
return an &App
and add sub_app_mut() -> &mut App
sub_app
return an &App
and add sub_app_mut() -> &mut App
It's sometimes useful to have a reference to an app a sub app at the same time, which is only possible with an immutable reference.