3 ms·
I always want to be careful with phrases like "bypassing safety checks", because of course the Vec/index pattern is 100% safe and (like any 100% safe Rust progr
by oconnor663 4y ago
I always want to be careful with phrases like "bypassing safety checks", because of course the Vec/index pattern is 100% safe and (like any 100% safe Rust program) will (approximately) never trigger undefined behavior. But it's true that what was formerly undefined behavior will still be a bug, where a stale index accidentally refers to a new object that happens to get allocated in the same spot. You can use slabs and generational indexes to catch these bugs, but I don't know whether the performance cost of generational indexes is acceptable in this case.
- ChickeNES 4y ago> here a stale index accidentally refers to a new object that happens to get allocated in the same spot. Given we're talking video games, you could also not worry and let speedrunners take advantage of it... ;)