I've been working on a UI library, which has an API that requires me to add elements to a
HashMap while returning references to its elements. (This is used to implement a version of React's
In order to accomplish that, I've written a wrapper type that allows me to do that. A slightly modified version with project-specific types is here.
While I'm reasonably confident in the code and it executes in Miri successfully, this is my first serious use of unsafe and I'd really appreciate some second opinions. Is this code, specifically the method
Thanks in advance!
Note: I have edited the example to add additional safety invariants in the comments.