You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1e7faef
Browse filesBrowse the repository at this point in the historyBrowse files
Belt.HashMap, Belt.HashMap.Int and Belt.HashMap.String gain
getWithDefault and getOrThrow, the same lookups Belt.Map and
Belt.MutableMap already have. They walk the bucket directly, so a hit
allocates no option; getOrThrow throws Not_found like the other Belt
maps.
Example (rescript):
let m = Belt.HashMap.Int.fromArray([(1, "a")])
m->Belt.HashMap.Int.getWithDefault(2, "z") == "z"
m->Belt.HashMap.Int.getOrThrow(1) == "a"
Review: Why getWithDefault and not getOr, as the issue title says? Belt
names this lookup getWithDefault everywhere (Option, Map, MutableMap and
their Int/String variants) and has no getOr; the new functions follow
Belt. getOrThrow is the name Belt already uses, without a deprecated
getExn alias for a new API.
Area: runtime tests
Output: changed tests/belt_tests/src/belt_hashmap_test.mjs (new tests); no
existing program compiles differently
Tests: ~tests/belt_tests/src/belt_hashmap_test.res plus docstring examples
in Belt_HashMap.resi, Belt_HashMapInt.resi, Belt_HashMapString.resi
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo
Signed-off-by: Christoph Knittel <ck@cca.io>
0 commit comments