Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRustPin Unpin and self-referenceSingle-choice MCQ

Given a `!Unpin` value behind `Pin<&mut T>`, why does `Pin::get_mut` not compile, while `Pin::get_unchecked_mut` does (with `unsafe`)?

use std::pin::Pin; use std::marker::PhantomPinned; struct S { _p: PhantomPinned } fn f(p: Pin<&mut S>) { let _m: &mut S = p.get_mut(); // error }