Module collections/entry

collections/entry
Stability: stable — one two-field struct, named after what it holds, and every map in `std` already returns it: nothing about it is still moving, and the maps that consume it could not change its shape without changing their own public signatures. `plans/STD_API_STABILIZATION.md` lists nothing open against it. — stable modules only change additively; this one may still change.

The key/value entry shared by every map in the standard library.

HashMap, BTreeMap, OrderedMap and imm.Map each used to declare their own identical struct(key, value) under a different name — Bucket, BTreeEntry, OrderedMapEntry and Pair respectively. One concept with four names meant an entry could not move between maps, and a reader could not tell from a signature whether two of them were the same shape. They are now this one type (plans/archive/STD_API_AUDIT.md D2, §5).

Not to be confused with the prelude's IterPair(A, B), which is struct(_0, _1) — a POSITIONAL pair produced by zip. A map entry is named: it has a key and a value.

Example

{ MapEntry } :: import("std/collections/entry");

e := MapEntry(String, i32)(key : `hits`, value : i32(3));
println(e.value);

Stability

stable — one two-field struct, named after what it holds, and every map in std already returns it: nothing about it is still moving, and the maps that consume it could not change its shape without changing their own public signatures. plans/STD_API_STABILIZATION.md lists nothing open against it.

Types

MapEntry type-function
fn(K : Type, V : Type) -> Type

A single key/value entry in a map.

Type Parameters

NameTypeNotes
KTypecomptime
VTypecomptime