weighted_pick

Function weighted_pick 

Source
pub fn weighted_pick<'a, T>(entries: &'a [(u32, T)], key: &str) -> &'a T
Expand description

The deterministic weighted pick over (weight, T) entries: the entry whose cumulative weight bound first exceeds pick_hash(key) % total. Mirrors dataplane::split’s slot walk over at most a handful of entries (validation bounds canary lists), so a linear scan is cheaper than any index. total must be > 0 (validation guarantees it: weights are >= 1 and the list non-empty).