Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's possible to cast the lifetime away. It's also easy to wrap it in a safe API: https://docs.rs/recycle_vec/latest/src/recycle_vec/lib.rs.ht... (libstd will likely add something like this).

However, the other issues they mention hit some well-known limitations of Rust, which don't always have a simple satisfactory solution. It's a valid criticism.

With a bit of `unsafe`, it's easy to force through self-referential structs incorrectly and violate exclusive ownership/aliasing rules (that's UB, in Rust!). Sometimes such code can be reorganized to avoid self-referential structs. With enough `unsafe` dark arts it's also possible to properly handle some self-references. However, in general it's typically a false positive in the borrow checker's model, and an annoying limitation.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: