我在尝试插入 Rust 中的 HashMap 时遇到错误。
use std::collections::HashMap;
fn main() {
let mut hm : HashMap<f64, i64> = HashMap::new();
hm.insert(1.0, 10);
}
错误:
Compiling playground v0.0.1 (/playground)
error[E0599]: the method `insert` exists for struct `HashMap<f64, i64>`, but its trait bounds were not satisfied
--> src/main.rs:5:8
|
5 | hm.insert(1.0, 10);
| ^^^^^^
|
= note: the following trait bounds were not satisfied:
`f64: Eq`
`f64: Hash`
For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground` due to previous error
有什么建议吗?