HashMap in Rust is a data-structure holding key-value pairs. Similar to hash in Perl and in other languages, dictionary in Python, and associative arrays in PHP, just to name a few.
Learn the basics about HashMap in Rust
- Create empty HashMap and insert key-value pairs -
new
,insert
,mut
. - Create empty HashMap in Rust without type definition.
- Initialize immutable HashMap with data -
from
,keys
,values
. - Check if key exists in HashMap - if the HashMap contains the key -
contains_key
. - Given a key, get value from a HashMap -
get
,Option
,match
.