-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Open
Description
In this part of code clippy error message not inline with the intent.
rustlings/exercises/22_clippy/clippy3.rs
Lines 20 to 21 in fbfd4f2
let my_empty_vec = vec![1, 2, 3, 4, 5].resize(0, 5); | |
println!("This Vec is empty, see? {my_empty_vec:?}"); |
Because the solution stated that this is about using clear
instead of resize
.
rustlings/solutions/22_clippy/clippy3.rs
Lines 20 to 23 in fbfd4f2
let mut my_empty_vec = vec![1, 2, 3, 4, 5]; | |
// `resize` mutates a vector instead of returning a new one. | |
// `resize(0, …)` clears a vector, so it is better to use `clear`. | |
my_empty_vec.clear(); |
elasticspoon
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
eduardotenholder commentedon Jan 27, 2025
Additionally
triggers in clippy:
triggers in me:
and it passes the test and I feel I got the point, but the solution tells me otherwise ...
securesvet commentedon Jun 1, 2025
I feel like this exercise is intended to show the common mistakes when writing in Rust
Mostly the common mistake is using resize and expecting the mutated vec as a return result
Shouldn't this be left as it is?
I guess, that the fixed error you've got in pull request should be discovered by the learner