§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.
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!