Skip to content
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

User story: unnecessary use of mutable smart pointer #25

Open
alice-i-cecile opened this issue Jul 5, 2022 · 0 comments
Open

User story: unnecessary use of mutable smart pointer #25

alice-i-cecile opened this issue Jul 5, 2022 · 0 comments
Labels
A-user-story Area: A user story or a related issue

Comments

@alice-i-cecile
Copy link

Lint explanation

Smart pointers often come in two forms. In bevy's case, the most common are typically Res and ResMut.

Users should only use this when necessary (i.e. when they actually intend to mutate the data), and should request the less powerful (more easily parallelized) immutable variant when they can.

As a result, using requesting a ResMut without actually making it mutable is almost always a mistake.

Example code

fn my_system(time: ResMut<Time>) {}

Should be

fn my_system(time: Res<Time>) {}

Notes

False positives may exist, e.g. with interior mutability, so advanced users need a way to locally allow this.

@alice-i-cecile alice-i-cecile added the A-user-story Area: A user story or a related issue label Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-user-story Area: A user story or a related issue
Projects
None yet
Development

No branches or pull requests

1 participant