std.map - ZZ
Pure-ZZ dict helpers over {K: V}: safe lookup, projections, merge. Dicts are insertion-ordered with O(n) lookup; the API is stable so a hashed implementation can drop in later without breaking callers.
import std.mapPurpose
Section titled “Purpose”std.map provides safe, fallible-free lookups and projections over dicts. No runtime errors on missing keys — use get_or for defaults. Both {str: int} and {str: str} variants exist (get_str, keys_str, values_str, merge_str). Ideal for configuration, lookup tables, and small-to-medium keyed data.
Conceptual model
Section titled “Conceptual model”Dicts are immutable values: map.merge, map.remove return a new dict; the original is unchanged. Lookup is O(n) (linear scan) — intentional for simplicity and stable iteration order. A future hashed implementation can replace the backing store without changing the API.
Quickstart
Section titled “Quickstart”import std.map
d := {"a": 1, "b": 2}map.get_or(d, "z", 99) // 99, no errormap.has(d, "a") // truemap.keys(d) // ["a", "b"]map.values(d) // [1, 2]map.merge(d, {"c": 3}) // {"a":1,"b":2,"c":3}map.remove(d, "a") // {"b":2}API reference
Section titled “API reference”12 entries. Signatures come from the compiler’s own FuncSig table, so they match the runtime exactly; descriptions come from the module guide.
See also
Section titled “See also”std.json— Parse, stringify and read individual values out of JSON.std.set— Arrays with uniqueness: membership, union, intersection and difference.std.dec— Exact decimal arithmetic carried as strings, so money never becomes a float.std.csv— An RFC 4180 subset: read rows, write rows, handle quotes and commas.std.property— Seeded generators and shrinking for property-based tests.
Full index: API reference · Standard library