Hacker News new | past | comments | ask | show | jobs | submit login

> We know that moving `Arc<Db>` will not change the location of the `Db` object, but there is no way to communicate this information to rustc.

There is! `std::pin`[0] does just this (and `Arc<T>` even implements `Unpin`, so the overall struct can be `Unpin` if everything else is `Unpin`). The page even includes a self-referential struct example, though it does use `unsafe`.

[0]: https://doc.rust-lang.org/std/pin/index.html




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: