Skip to main content

Module maps

Module maps 

Source
Expand description

Map[K, V], Set[T], and Counter[T] (§6.1, §11.3).

All three reuse Rust’s hash collections behind opaque GC objects:

  • Map[K, V]HashMap<DynamicKey, GcRef> (§11.3)
  • Set[T]HashSet<DynamicKey> (§11.3)
  • Counter[T]HashMap<DynamicKey, GcRef> with Int values (§6.2)

DynamicKey (dynamic_key.rs) bridges Praxis values into Rust’s Hash/Eq by delegating to the descriptor’s hash/equals callbacks — the mechanism that lets tuples and records be keys. A non-hashable key type (closure) is rejected at the capability layer (supports_hash) before reaching here.

Counter’s defining behavior (§6.2): absent keys read as zero, never fault. min=/max= map updates (§6.2) live in the ABI wrappers.

Structs§

CounterPayload
The Counter[T] payload (§6.2, §11.3). A map whose values are always Int and whose absent keys read as zero. Backed by HashMap<DynamicKey, GcRef> where each value is a boxed Int; the key descriptor selects hash/eq.
MapPayload
The Map[K, V] payload (§11.3). Both descriptors are labels: what the construction site knew about the type, or null when it knew nothing. Neither is the authority for an element-wise operation — every key carries its own descriptor on its DynamicKey and every value carries one in its object header, and that is what format/equals/hash dispatch through. ADR-066 decision 5 is the rule: a null descriptor slot is legal and means “the value’s own descriptor answers”. A non-nullable label would force praxis_map_new to spell an unknown type as INT, and anything that trusted it would read a Map[Text, Text]’s values as i64.
SetPayload
The Set[T] payload (§11.3). The element descriptor is a label — what the construction site knew, or null when it knew nothing. Each member’s DynamicKey carries its own descriptor, which is what hash and format dispatch through.

Statics§

COUNTER
Descriptor for Counter[T] (§6.2).
MAP
Descriptor for Map[K, V] (§11.3). Per-instance key/value types live in the payload, so a single descriptor serves all Map[K, V].
SET
Descriptor for Set[T] (§11.3).