-
Notifications
You must be signed in to change notification settings - Fork 1.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
new lint: vec.drain(..)
instead of vec.clear()
#9339
Comments
@rustbot claim |
@rustbot claim |
@rustbot claim |
Hi @lana99, are you working on this or is this up for grabs? |
I’ve been busy but I will probably push code for the issue this weekend. @czotomo |
Hi @lana99, I don't know if you are still working on this but as I was looking at #9623 I was thinking that the example in the documentation you provided might be improved from this: let mut vec: Vec<i32> = Vec::new();
vec.drain(..); to this: let mut v = vec![0, 1, 2];
v.drain(..); to make it conform to the examples of the Drain documentation and the Vec documentation. Sorry if this isn't the place to discuss this, and I don't mean to be nosy, I was just trying to learn from other people's PR how to contribute and yours caught my attention 🙂 |
Ah great, im not working on it anymore , so its up for grabs :) |
@flip1995 I would like to pick up where @lana99 left off, but first I would like suggest renaming the lint. I looked at #9623 and saw that you suggested renaming
My point is, while looking at existing lints it occurred to me that Any thoughts? |
@rustbot claim |
Hi @philpax, I started working on this but I'm a newbie and I have some questions :) (on the lint itself, not necessarily on how to contribute). Do you know of anyone who might have some time to mentor me? The active members link in CONTRIBUTING.md seems to be pointing to a file that does not exist anymore, so I am to sure who I can contact. Cheers |
I'm afraid not - I'm just a user myself! I'd suggest going to the |
Oh I see! I'll do that, thank you 🙂 |
What it does
Checks for usage of
vec.drain(..)
(iterator dropped immediately) which can be replaced withvec.clear()
Lint Name
unnecessary_vec_drain
Category
style
Advantage
Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: