Misc 4 @BoxyUwU
Warning: this quiz is still "work-in-progress", some questions might not have good explanations (or any at all), formatting/structure/titles/etc are not final, and so on. You might want to return here on a later date.
fn main() {
let mut map = HashMap::new();
map.insert(1, 2);
assert_eq!(map.get_mut(&1), Some(&mut 2));
}
Solution
error[E0433]: failed to resolve: use of undeclared type `HashMap`
--> examples/misc_4.rs:2:19
|
2 | let mut map = HashMap::new();
| ^^^^^^^ use of undeclared type `HashMap`
|
help: consider importing this struct
|
1 + use std::collections::HashMap;
|
For more information about this error, try `rustc --explain E0433`.
error: could not compile `code` (example "misc_4") due to 1 previous error
This is a trick question (as they all are in this quiz though), HashMap
is not included in the prelude and so must be imported explicitly.