News for hackers. Stuff that matters.
Re:How safe is Zig? by veber-alex on Thursday June 23, 2022 @08:45PM (#31856749)
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

Re:How safe is Zig? by verdagon on Thursday June 23, 2022 @09:08PM (#31856860)
You 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...