Skip to main content

pack

Function pack 

Source
pub const fn pack(layer: Layer, freq_score: u64) -> u64
Expand description

Pack (layer, freq_score) into a single u64 index value. freq_score is saturated to MAX_FREQ_SCORE if it exceeds the field, never wrapped: for an order-by-value structure a wraparound would invert priority (a very high freq would pack to a tiny value and rank last), whereas clamping keeps “higher freq → higher-or-equal priority”. Real freqs (≤ ~50k) are far inside the field, so this only matters as a defensive guarantee.