cargo clippy

cargo clippy(smart compiler) is a tool to catch:
- Linting issues
- rust idiomatic, efficient, and maintainable code
- It doesn't just check for bugs; it suggests better ways to write logic
- warns about performance pitfalls
- Common mistakes and improve your Rust code
- adhere to the community-standard Rust style

cargo build/run is standard Rust compiler (rustc) focuses on ensuring your code is valid and safe


fn main() {
    let my_vec = vec![1, 2, 3];
    for i in 0..my_vec.len() {
        println!("{}", my_vec[i]);
    }
}
      

$ cargo clippy

Standard Error

warning: the loop variable `i` is only used to index `my_vec`
help: consider using an iterator
3 -     for i in 0..my_vec.len() {
3 +     for <item> in &my_vec {
  |

warning: useless use of `vec!`
2 |     let my_vec = vec![1, 2, 3];
help: you can use an array directly: `[1, 2, 3]`
          

$ cargo build
no issues