Closed
Description
#![allow(unused_variables)]
fn main() {
use std::collections::HashMap;
let mut hash = HashMap::<u32, Vec<u32>>::new();
let foo = hash.entry(1).or_insert(vec![]);
}
Gives:
warning: use of `or_insert` followed by a function call
--> src\main.rs:5:15
|
5 | let foo = hash.entry(1).or_insert(vec![]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(or_fun_call)] on by default
help: try this
| let foo = hash.entry(1).or_insert_with(|| < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] ));
= help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#or_fun_call
A nicer looking warning should show .or_insert_with(|| vec![]);
Metadata
Metadata
Assignees
Labels
No labels