tom heavily uses indices to refer to tree nodes. This has an obvious problem that you can accidentally use index from file A with file B, and get a mysterious error down the line. We can use a trick to help to catch such errors earlier however! The idea is, when cfg(debug_assertions) is active, to add some runtime-checks. Specifically:
Add a global atomic 8-bit counter which is inremented every time a file is created.
Add a 8-bit nonce field to file, initialized from the global counter.
Use the highest 8 bits of the node id to store the nonce
tom
heavily uses indices to refer to tree nodes. This has an obvious problem that you can accidentally use index from fileA
with fileB
, and get a mysterious error down the line. We can use a trick to help to catch such errors earlier however! The idea is, whencfg(debug_assertions)
is active, to add some runtime-checks. Specifically: