3 ms·
But from what I've seen, most idiomatic Rust code doesn't use the `map[key]` syntax, but instead uses `map.get(key)`.
by Ar-Curunir 8y ago
But from what I've seen, most idiomatic Rust code doesn't use the `map[key]` syntax, but instead uses `map.get(key)`.
- steveklabnik 8y agoWe must look at very different code :)
- bpicolo 8y agoI actually didn't realize it was doable (not a heavy rust user - just an enthusiast). Kinda hidden away in docs under an example [0] and isn't in the book under hash maps [1]. Might be worth calling out somewhere explicitly? People getting started with rust probably aren't familiar with the trait-based operator overloading system yet. [0] https://doc.rust-lang.org/std/collections/struct.HashMap.html#examples-16 https://doc.rust-lang.org/std/collections/struct.HashMap.htm... [1] https://doc.rust-lang.org/book/second-edition/ch08-03-hash-maps.html https://doc.rust-lang.org/book/second-edition/ch08-03-hash-m...
- steveklabnik 8y agoYeah, might be worth it on the API docs, for sure. Maybe file a bug? :)