1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//! Fast non-cryptographic hashing: the estate's canonical map hash.
//!
//! FxHash-family multiply-xor accumulation over 8-byte chunks, with
//! two correctness features the family usually skips (both found by
//! this crate's own property suite, see git history):
//!
//! - **Streaming-correct**: values are buffered through an 8-byte tail
//! and flushed on chunk boundaries, so `write(a); write(b)` produces
//! exactly the same state as one `write(a ++ b)` - for every split.
//! Hashing a struct's fields piecewise (the `Hasher` contract) is
//! therefore equivalent to hashing the serialized whole.
//! - **Finalized**: `finish` applies a splitmix-style mix so the
//! avalanche ratio lands near 50% (the raw recurrence measured
//! 0.387 - below the kit's [0.40, 0.60] window).
//!
//! Two surfaces:
//! - [`FastHasher`]: a [`core::hash::Hasher`] implementation, drop-in
//! for `HashMap<K, V, FastHashBuilder>`.
//! - [`hash64`]: the one-shot byte-slice hash, for non-`Hash` inputs
//! and for cross-referencing stored hashes. Stable across versions
//! and processes (documented contract; `FastHasher`'s raw state is
//! NOT stability-claimed).
//!
//! Non-cryptographic by design: no collision-resistance claims;
//! security-adjacent uses belong to the keyed-crypto domain.
//!
//! Hot path contract: no panics, no allocation, no syscalls, `no_std`.
extern crate alloc;
use Hasher;
/// The forever-oracle: an independent byte-assembly formulation of
/// the hash, differential-tested against the optimized forms. Never
/// optimized, never deleted (kit AGENTS.md).
/// The `FxHash` 64-bit multiplier: `(2^64 + 2^5) / 5`, chosen so the low
/// bits spread through the multiply; the standard family constant.
const SEED: u64 = 0x51_7c_c1_b7_27_22_0a_95;
/// The splitmix64 finalizer constants: one multiply-xor-shift round
/// takes the accumulator's avalanche ratio from 0.39 to ~0.50.
const FINALIZE_A: u64 = 0xFF51_AFD7_ED55_8CCD;
const FINALIZE_B: u64 = 0xC4CE_B9FE_1A85_EC53;
/// The FxHash-family hasher: a [`core::hash::Hasher`] for
/// `HashMap<K, V, FastHashBuilder>` and direct byte hashing.
///
/// Streaming-correct (see above): `write` calls may split anywhere.
/// Not cryptographically stable in its raw state; the one-shot
/// [`hash64`] documents its stability instead.
/// The standalone byte-slice hash: one-shot, **stable across versions
/// and processes**. This is the contract that differs from
/// [`FastHasher`]'s raw state, whose finalization constants may change
/// on a version bump (map ordering is not a persisted contract).
///
/// Identical to `FastHasher::write_bytes` + `finish` (property-tested).
/// The builder for `HashMap<K, V, FastHashBuilder>` (the
/// `BuildHasher` contract).
;