15

I was looking for the way to create an associative array in the documentation but didn't find anything. So how do I create an associative array in Rust?

hippietrail
  • 15,848
  • 18
  • 99
  • 158
Incerteza
  • 32,326
  • 47
  • 154
  • 261

1 Answers1

23

What you know as an associative array is also known by some other names, such as a dictionary or a map.

In Rust, it’s called a map, and is epitomised in the HashMap type.

Chris Morgan
  • 86,207
  • 24
  • 208
  • 215
  • 1
    When you want ordered associative array, there is also [`BTreeMap`](https://doc.rust-lang.org/std/collections/struct.BTreeMap.html). – Code4R7 Jul 17 '22 at 04:52