Coroutines, Self-Referential Structs, and Pinning 238 println!("{}", x. as_ref(). a); } The noticeable difference here is that it's unsafe to pin to the stack, so now, we need unsafe both as users of Maybe Self Ref and as implementors. If we run the example with cargo run, the output will be the same as in our first example: Finished dev [unoptimized + debuginfo] target(s) in 0. 58s Running `target\debug\x-pin-experiments. exe` 0 2 The reason stack pinning requires unsafe is that it's rather easy to accidentally break the guarantees that Pin is supposed to provide. Let's take a look at this example: ch09/d-pin/src/main. rs use std::mem::swap; fn stack_pinning_manual_problem() { let mut x = Maybe Self Ref::default(); let mut y = Maybe Self Ref::default(); { let mut x = unsafe { Pin::new_unchecked(&mut x) }; x. as_mut(). init(); *x. as_mut(). b(). unwrap() = 2; } swap(&mut x, &mut y); println!(" x: {{ +----->a: {:p}, | b: {:?}, | }} | | y: {{ | a: {:p}, +-----|b: {:?}, }}", &x. a, x. b, &y. a, y. b, ); }