Using Pin
might overcomplicate things because the invariants it provides aren't necessarily the invariants that you expect. Pin is... subtle.
I've been playing around with unsafe
Rust for several years now and would consider myself quite an advanced user, and even I got tricked by thinking (the equivalent of) Pin<&mut Plane>
would guarantee the data doesn't move. To actually guarantee it can't be moved you need to make sure Plane: !Unpin
, which is only possible in stable Rust by adding a std::marker::PhantomPinned
to the type.