fix(clippy3): separate initialisation and resizing of vec #2302
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi rustlings team! Thank you all for maintaining this amazing resource for learning Rust.
I had recently gone through the clippy exercises and I noticed that in clippy3 one of the things clippy is supposed to pick up on is to suggest
clear
ing aVec
instead ofresize
ing it to len 0 (at least judging from the current example solution for the exercise). In the current form of the exercise, clippy actually doesn't do this and instead just tells you to not initialise aVec
and then immediately resize it to len 0 (it is currently all done in one line) (tbf that is fair advice by clippy!).But if you would like the intended advice of "you should use clear instead", you can get that by separating the initialisation and the resizing. This is a tiny PR just doing that.