4 ms·
An additional short-and-sweet example, using HashMap: use std::collections::HashMap; fn main() { let mut foo = HashMap::new(); foo
by kibwen 6y ago
An additional short-and-sweet example, using HashMap:
use std::collections::HashMap;
fn main() {
let mut foo = HashMap::new();
foo.insert("bar", 42);
}
In C++, the declaration of `foo` would require a type annotation like `map<string_view, int>`.
- steveklabnik 6y ago(you need foo.insert, but yes)
- kibwen 6y agoEr, you haven't heard about Rust's new feature where it treats all common metasyntactic variable names as interchangeable? :P
- steveklabnik 6y agoHa! Well, I just realized I messed up left and right in my post so... we all do it.