use std::collections::HashMap;
fn main() {
let mut map: HashMap<&str, Vec<i32>> = HashMap::new();
map.entry("bar").or_insert_with(|| vec![]);
}
This will cause clippy to lint:
warning: redundant closure found
--> src/main.rs:5:37
|
5 | map.entry("bar").or_insert_with(|| vec![]);
| ^^^^^^^^^ help: remove closure as shown: `$crate::vec::Vec::new`
|
= note: `#[warn(clippy::redundant_closure)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: 1 warning emitted
When using vec![], clippy will suggest $crate::vec::Vec::new which seems a bit complex given that we could just suggest Vec::new (without the path)?
This will cause clippy to lint:
When using
vec![], clippy will suggest$crate::vec::Vec::newwhich seems a bit complex given that we could just suggestVec::new(without the path)?