Open
Description
I tried this code:
fn main() {
let map: HashMap<i32, i32, _> = HashMap::from_iter(vec![(1, 1), (2, 2)].into_iter());
}
I expected to see this happen:
when run cargo check
, it should says
--> src/main.rs:30:14
|
30 | let map: HashMap<i32, i32, _> = HashMap::from_iter(vec![(1, 1), (2, 2)].into_iter());
| --- ^^^^^^^^^^^^^^^^^^^^ cannot infer type
| |
| consider change `HashMap<i32, i32, _>` to `HashMap<i32, i32>` because it has a default type, or specify a detail type.
Instead, this happened:
--> src/main.rs:30:14
|
30 | let map: HashMap<i32, i32, _> = HashMap::from_iter(vec![(1, 1), (2, 2)].into_iter());
| --- ^^^^^^^^^^^^^^^^^^^^ cannot infer type
| |
| consider giving `map` the explicit type `std::collections::HashMap<i32, i32, _>`, with the type parameters specified
Meta
rustc --version --verbose
:
ustc 1.43.0-nightly (a1912f2e8 2020-02-12)
binary: rustc
commit-hash: a1912f2e89b77cfe2a0e64b96f444848fe4e2d49
commit-date: 2020-02-12
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0