I put together a post about handle lookup containers (also known as sparse sets) here - https://tomhultonharrop.com/c++/lookup/handle/2024/01/07/handle-lookup-container.html. Very much inspired by the work of @niklasgray, @floooh and Noel Llopis.
@tom_h_h @niklasgray @floooh Some extra wild ideas perhaps:
0) the first issue isn't a problem for rust :)
1) mix the handles based on the address of the pool they come from to help detect cases where you access the wrong pool with a handle https://github.com/jsimmons/narcissus/blob/main/engine/narcissus-core/src/pool.rs#L36-L104
2) instead of killing the slot after running out of space, i maintain some extra slots always available, to extend the power of the small generation counter. https://github.com/jsimmons/narcissus/blob/main/engine/narcissus-core/src/pool.rs#L23-L26