4 ms·
If you are holding indexes to a collection and plan to delete elements you will never use Vec. There are dedicated data structures for this [1] that will not l
by veber-alex 4y ago
If you are holding indexes to a collection and plan to delete elements you will never use Vec.
There are dedicated data structures for this [1] that will not let you access another item by mistake.
[1] https://crates.io/crates/slotmap https://crates.io/crates/slotmap
- verdagon 4y agoYou should never use Vec in that situation, but we see it all the time. People love indexing into Vecs and reusing elements. One of my favorite alternatives is generational_arena [0] which also happens to be the library that inspired Vale's generational references! [0] https://docs.rs/generational-arena/latest/generational_arena/ https://docs.rs/generational-arena/latest/generational_arena...