Post

Continuing on my crackpot theories of contravariant lifetimes, here's an interesting alternative formulation of Rust Pin: a pinned type holds a reference to itself (potentially inside a PhantomData). Moving the item invalidates that reference, so it invalidates the type.

That reference is (arguably, probably) contravariant; it can be covariant as well because we get invariance in either case, but contravariance I believe gives better semantics because conceptually the contravariant ref can never read self: hence taking &mut self is okay despite the self-reference.

0 reposts0 likes

No replies yet.