Blog: Clippy vs. Rust

Wherein I compile clippy with Rust and vice versa.

Are you using clippy? If so, please share your experience here!


I tried it and thought it was nifty. I'm not inclined to keep it enabled. I'd just use it occasionally to see if anything is stale.

I liked how it pointed out returns which aren't needed and len() can be replaced with is_empty(). Wouldn't have caught them manually.

match into if let is iffy. match handles a complex situation in a cleaner fashion and so it depends on the case.

1 Like

Thanks! I'm glad you like it.

I'd just use it occasionally to see if anything is stale.

Yeah, that's how I use clippy, too. Others I know use it continually. The good thing is that everyone can use it how they like.

match into if let is iffy.

I used to think so, too, but it's growing on me. The reason if let is better for some cases is that match incurs one more level of indentation, which usually makes the code harder to read. If that wasn't the case, if let wouldn't even be in the language.

You are correct but sometimes the rightward shift is nearly irrelevant. I also liked "replace unwrap() with expect()". I don't know if I'd always do it, but it was useful.

I agree that it's a matter of taste, so we can argue all we want about it :smile:

The "replace unwrap() with expect()" lint is also just a wee bit problematic IMHO, because it doesn't catch things like if x.is_some() { ... x.unwrap() ... } else { ... }, which, while not exactly Rusty, is clearly correct code. Perhaps we should have another lint that would suggest to use if let Some(some_x) = x { ... some_x ... } else { ... } instead.

1 Like