BuiltinHashKey
Proves the canonical default logical hash/equality operations for built-in keys. Admitted keys are integers, byte, IEEE numbers, bool, char, str and String. The compiler binds exact existing standard implementations; custom owners use an explicit HashKeyPolicy instead. No runtime witness, allocation, storage or lifecycle permission is introduced. Borrowed text keys still need live backing.
Module std.collections
import std.collections;Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.
BuiltinHashKey
pub concept BuiltinHashKey<Self>Proves the canonical default logical hash/equality operations for built-in keys. Admitted keys are integers, byte, IEEE numbers, bool, char, str and String. The compiler binds exact existing standard implementations; custom owners use an explicit HashKeyPolicy instead. No runtime witness, allocation, storage or lifecycle permission is introduced. Borrowed text keys still need live backing. Self: Exact supported key representation.
Example
module example.builtin_hash_key;
from std.collections import BuiltinHashKey;
fn SameKey<K>(Left: readonly K&, Right: readonly K&) -> bool where K: BuiltinHashKey {
if !K.EqualBuiltinKeys(Left, Right) { return false; }
// Equality implies equal hashes; unequal keys can still collide.
return K.HashBuiltinKey(Left) == K.HashBuiltinKey(Right);
}
fn Main() -> i32 {
if !SameKey(42_i32, 42_i32) || SameKey(42_i32, 43_i32) { return 1; }
if !SameKey('λ', 'λ') || SameKey('λ', 'A') { return 2; }
if !SameKey("key", "key") || SameKey("key", "other") { return 3; }
return 0;
}