-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Warn about using Arc::new() when using the vec![value; size] macro. #8719
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
@rustbot label +good-first-issue |
Hello there!
|
Thanks a lot! |
I believe this lint could apply equally to |
The pr is updated to support |
Just wanted to hop on and say thanks to @yonip23... pretty amazing to me that someone picked this up and that it's almost done two weeks later. |
@davidbeesley I'm excited myself to contribute to this amazing project! Thanks for the shout-out, appreciate it 🙏 |
What it does
This lint would warn against using Arc::new in the vec![value; size] macro, because it computes the value once and then clones the value size times instead of generating a new Arc each of the size times.
If the user truly wants a vector of Arcs all pointing to the same arc, then they should make that obvious by constructing the arc before constructing the vector.
Lint Name
No response
Category
No response
Advantage
No response
Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: