4 ms·
How would a self-referential object work in Rust in that case? The move or copy constructor could not be a simple memcpy. The self-reference would point to the
by rustmemcpy 10y ago
How would a self-referential object work in Rust in that case?
The move or copy constructor could not be a simple memcpy.
The self-reference would point to the old object. See this for an example:
http://ideone.com/sEFtbN http://ideone.com/sEFtbN
- sirclueless 10y agoSee steveklabnik's detailed answers elsewhere in this thread, but the short answer is that you can't write this data type in Rust.
- Manishearth 10y agohttps://github.com/Kimundi/owning-ref-rs https://github.com/Kimundi/owning-ref-rs exists, but basically you just don't do intrusive datastructures on the stack in rust. (Intrusive datastructures on the heap are doable with some tricks.) They're not very essential so it works out.