Skip to content

Glossary: Data Structures and Algorithms in Rust

entry().or_default()

Also written: entry, or_default, or_insert

A HashMap pattern that finds the value for a key, or creates a default one (an empty Vec, or 0 with or_insert(0)) if the key is new. It is used to count items and to add neighbors to a graph.

Where the book teaches it

Related terms

Hash mapAdjacency list