Re:Unsoundness in Pin
by epage on Friday November 29, 2019 @11:05AM
(#21665114)
> But it turns out that it's possible that Rust may not have been radical enough! Consider: what if you want a type that not only can't be copied, but can't be moved as well?
When talking about Pin, I think it is important to go back to a more fundamental level.
There are types that are not movable without extra processing, like a `struct` that has fields that reference other fields. When moving, those references become invalid.
Rust chose by allowing types to become unmovable so the `struct` can't go into an invalid state.
While C++ doesn't have the same safety guarantees, they did need to solve this problem. C++ chose to solve this with move constructors. I know move constructors will have their own challenges in Rust but I hope we do get them one day.
Re:Unsoundness in Pin
by zozbot234 on Friday November 29, 2019 @11:14AM
(#21665161)
There is an unofficial 'transfer' crate that builds on Pin<> and on a further unofficial "stackpin" feature (pinning objects on the stack, which is currently not provided for in standard Rust) to provide an equivalent to C++ move constructors.
When talking about Pin, I think it is important to go back to a more fundamental level.
There are types that are not movable without extra processing, like a `struct` that has fields that reference other fields. When moving, those references become invalid.
Rust chose by allowing types to become unmovable so the `struct` can't go into an invalid state.
While C++ doesn't have the same safety guarantees, they did need to solve this problem. C++ chose to solve this with move constructors. I know move constructors will have their own challenges in Rust but I hope we do get them one day.