Module collections/entry
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/archive/STD_API_STABILIZATION.md lists nothing open
against it.
Types
A single key/value entry in a map.
Type Parameters
| Name | Type | Notes |
|---|---|---|
K | Type | comptime |
V | Type | comptime |
Trait Implementations
impl(generic(T : Type), where(T <: Clone), T : (Clone))
impl(generic(T : Type), where(T <: Clone), T : (Clone), CloneInto)
clone_into : fn(self : &Self, dst : *(Self)) -> unitWrite a clone of self into the uninitialized slot dst, which has
room for size_of_val(self) bytes at align_of_val(self).
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | |
dst | *(Self) |
Returns: unit