← All notes

HashMap in Rust

Answer: The type HashMap<K, V> stores a mapping of keys of type K to values of type V using a hashing function, which determines how it places these keys and values into memory. Where vectors store values by an integer index, HashMaps store values by key. (S1, S2)

Basics

Keys and size

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Rust Programming Language, Storing Keys with Associated Values in Hash Maps - The Rust Programming Language, MIT or Apache-2.0 (rust-lang/book; Copyright (c) 2010 The Rust Project Developers; https://github.com/rust-lang/book/blob/main/LICENSE-MIT); Rust by Example, HashMap - Rust By Example, MIT or Apache-2.0 (rust-lang/rust-by-example; Copyright (c) 2014 Jorge Aparicio; https://github.com/rust-lang/rust-by-example/blob/master/LICENSE-MIT).

Cite this

Permanent ID: iil:note:3v8y8sjs

iinventedlight. 2026. "HashMap in Rust." iinventedlight Library, iil:note:3v8y8sjs, version of 2026-11-04. https://iinventedlight.com/library/notes/rust-hash-maps/. License: CC-BY-4.0.

@misc{iil_note_3v8y8sjs,
  author = {{iinventedlight}},
  title = {{HashMap in Rust}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/rust-hash-maps/},
  note = {Permanent ID iil:note:3v8y8sjs. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/rust-hash-maps.md.