It's not a complete definition (but I agree that is a very nice short way to describe the main point of using Pin
) though, since Pin
interacts very heavily with Drop
semantics: Pin
implies not only that the pointee has a "fixed address" ... but also that such address must remain valid until the pointee is dropped. That is, Pin
is also a way to opt-out of compile-time lifetimes / borrows while still keeping some invariants; c.f. my post about it:
Suffices to say, Pin
is very complex abstraction; the property of "preventing ill-formed mempcy
s" can be more easily provided by immutable heap pointers than by these advanced Pin
ned pointers. Only use the latter if you do need some form of (restricted) mutation anyways, and/or if you want to support such stack pointers (what most other languages do not even dare do).