-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Gave bevy::app::App the must_use attribute #20995
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
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
This doesn't fix #5386 If you add plugins but still don't call |
thanks for the feedback! I'll look into this now |
The base issue is not really trivial in my opinion. This PR is good and could be merged as is, but it shouldn't say it fixes the issue as that will close it. You can spend some time to investigate in this PR if you want, or you can edit the description and we can merge this now while you investigate with another PR |
So I found the obvious solution of just marking all of the App::new()
.add_plugins(DefaultPlugins)
.insert_resource(MyResource::Default())
.run(); The point is to give us a warning if we ever forget the last line. But this doesn't support the other, completely valid use which is more along the lines of let app = App::new();
app.add_plugins(DefaultPlugins);
app.insert_resource(MyResource::Default());
app.run(); Because in this case, it'll warn us on both of those middle lines if we don't put |
Hmm, yeah, I don't think we should break the multi-line pattern. I'm a bit skeptical of the panic idea: I think that it's a lot of complexity and risk to solve a beginner footgun. Simply marking |
no panic for me: the idea is to warn the user in their IDE, they'll notice soon enough that nothing happens when they run it |
alright, sounds good. I'll edit the description to remove the fix. Thanks for the good feedback! |
Objective
Attempts #5386
Solution
Added the
must_use
attribute tobevy::app::App
Testing
I tested it by linking the library to another cargo package and calling App::new() without using the return value.
(this is my first pr, so i just chose something very easy.)