Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
Development · Evolving reference

HashKeyPolicy

Defines the exact safe readonly hash/equality operations for a key type.

Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. Read the status →

Module std.collections

import std.collections;

Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.

HashKeyPolicy

pub concept HashKeyPolicy<Self, K>

Defines the exact safe readonly hash/equality operations for a key type.

Equals must be an equivalence relation. Equal keys must hash equally; hash and equality results must remain stable while keys are stored. Neither operation may mutate or invalidate owning container storage. These semantic laws are caller obligations beyond structural signature checking. Calls retain no key borrow and introduce no required allocation, locking, boxing or unsafe effect. Self: Concrete owned policy type. K: Exact key type, borrowed readonly by both operations.

HashKeyPolicy.Hash

requires readonly fn Hash(Key: readonly K&) -> u64;

Computes a stable hash of one readonly key. Key: Borrowed key; not retained after the call. Return: Hash value; equal keys must produce equal values.

HashKeyPolicy.Equals

requires readonly fn Equals(Left: readonly K&, Right: readonly K&) -> bool;

Tests key equivalence without mutating either input. Left: First readonly borrowed key. Right: Second readonly borrowed key. Return: Whether the keys represent the same logical key.

Documentation snapshot: October 24, 2026 About versions ↗
Searching Development · language & standard library