Recently ran into a situation where self referential structs would have been a nice solution, and while I found a decent amount of discussion around the topic I didn't find a satisfying solution. So begrudgingly I unpacked to unsafe hammer and got to work.
I'd really appreciate any feedback from API to soundness. Note, the documentation is still very rudimentary and I plan to properly document all functions and traits. But before that it would be great if some more experienced people than me could take a look at the unsafe in https://github.com/Voultapher/once_self_cell/blob/main/src/once_self_cell.rs, going through the nomicon I couldn't find a way this could be used to trigger UB, and so far miri agrees with me https://github.com/Voultapher/once_self_cell/runs/1538569928
One of the core motivations for this was that rental is heavy to compile and no longer maintained, while this is pretty minimal:
Compiling once_cell v1.5.2 Compiling once_self_cell v0.1.0 Completed once_cell v1.5.2 in 0.9s Completed once_self_cell v0.1.0 in 0.3s