§2️⃣ Next Steps

2025-04-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX, Daniel Pfeiffer

In the first part we explored how to do complex things at compile time in (or despite) const. Building a specialised complete binary tree in an array proved quite feasible. Actually this required some puzzle pieces that only dropped in recent improvements of Rust.

TL;DR We built a tree where the span of each node reflects its weight. The spans are spread across the full range of possible values. That way any given value can be quickly looked up. E.g. lookup by a plain random number thus gives you a weighted random.

134 183 'A' 55 100 'B' 204 239 'C' 14 45 'D' 107 134 'E' 183 204 'F' 239 256 'G' 0 14 'H' 45 55 'I' 100 107 'J'

While the tree was already fully functional, it did leave open various areas of improvement. Let’s go for a walk in the woods and see!

§More Coming…