Skip to main content

Module dynamic_key

Module dynamic_key 

Source
Expand description

The DynamicKey wrapper for hash-based collections (§11.3).

Map[K, V], Set[T], and Counter[T] reuse Rust’s HashMap/HashSet behind opaque GC objects. Rust needs Hash + Eq on its key type, but a Praxis key is a uniform GcRef whose structural identity is defined by the value’s type descriptor (§5.5, §11.3): DynamicKey is the bridge.

A DynamicKey stores the rooted GcRef plus its descriptor. Its Rust Hash/Eq delegate to the descriptor’s hash/equals callbacks (§11.3: “Its Rust Hash and Eq implementations delegate to descriptor functions generated or selected by the compiler”). The static type checker guarantees one collection instance receives only its declared key type, so all keys in one map share a descriptor; a non-hashable type (e.g. a closure) has hash/equals == None and is rejected at the capability layer (supports_hash, §5.5) before reaching here.

DynamicKey is a Rust-internal type: it never crosses the ABI and has no TypeId. The GC traces the underlying values through the collection’s own trace callback (which iterates the map/set entries), so DynamicKey itself carries no GC-rooting responsibility.

Structs§

DynamicKey
A Praxis value used as a hash-collection key, paired with its descriptor so Rust’s HashMap/HashSet can hash and compare it structurally (§11.3).