Open
Description
In many blog posts online I see code like:
fn main() {
let a = vec![10, 20, 30];
let tot: u32 = a.iter().sum();
println!("Total: {}", tot);
}
I'd like a Clippy lint that suggests to write instead:
fn main() {
let a = [10, 20, 30];
let tot: u32 = a.iter().sum();
println!("Total: {}", tot);
}
That is, to suggest to use arrays in simple cases where dynamic arrays aren't necessary. Even if such lint is very conservative it's still going to be useful to teach inexperienced Rust programmers to avoid heap allocations (Clippy is also a learning tool today). Rust programmers later could remember the idea and generalize it.