rustlings icon indicating copy to clipboard operation
rustlings copied to clipboard

Clippy3: error message from clippy not inline with the intent

Open sugab opened this issue 11 months ago • 2 comments

In this part of code clippy error message not inline with the intent.

https://github.com/rust-lang/rustlings/blob/fbfd4f25e7e715007f5f3f6678f5d336d24d3660/exercises/22_clippy/clippy3.rs#L20-L21

Image

Because the solution stated that this is about using clear instead of resize.

https://github.com/rust-lang/rustlings/blob/fbfd4f25e7e715007f5f3f6678f5d336d24d3660/solutions/22_clippy/clippy3.rs#L20-L23

sugab avatar Jan 21 '25 04:01 sugab

Additionally

if my_option.is_none() {
  println!("{:?}", my_option.unwrap());
}

triggers in clippy:

help: remove the `None` and `unwrap()`

triggers in me:

if my_option.is_none() {
  println!("{:?}", my_option);
}

and it passes the test and I feel I got the point, but the solution tells me otherwise ...

eduardotenholder avatar Jan 27 '25 14:01 eduardotenholder

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

securesvet avatar Jun 01 '25 22:06 securesvet