---
title: HashMap (hash, dictionary, associative array) in Rust
timestamp: 2024-04-25T09:55:01
author: szabgab
published: true
description: Learning about Hashes in Rust
tags:
    - HashMap
todo:
    - TODO
---


[HashMap](https://doc.rust-lang.org/std/collections/struct.HashMap.html) 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](/create-empty-hashmap-and-insert-pairs) - `new`, `insert`, `mut`.
* [Create empty HashMap in Rust without type definition](/create-empty-hashmap-without-type-definition).
* [Initialize immutable HashMap with data](/initialize-hashmap-with-data) - `from`, `keys`, `values`.
* [Check if key exists in HashMap - if the HashMap contains the key](/check-of-key-exists-in-hashmap) - `contains_key`.
* [Given a key, get value from a HashMap](/get-value-from-hashmap) - `get`, `Option`, `match`.

## Some more advanced topics aboit HashMap in Rust

* [Convert hash to hash in Rust](/convert-hash-to-hash)
* [Pass a mutable hash to a function in Rust](/pass-mutable-hash-to-function)
* [Rust HashMap where tuples are the keys](/hash-where-tuples-are-the-keys)

* [Serialize and deserialize HashMap to JSON in Rust](/serialize-hash-to-json)

## Uses of HashMap

* [Embedding simple CSV file in Rust application](/embedding-simple-csv-file)
* [Count distribution of values - how many times each word appears in a list of words](/count-distribution-of-values)
