std-module
std::pin: location stability
Pinning constrains moving or invalidating an address-sensitive pointee after pinning, not moving the pointer handle. Ordinary movable values can be pinned too. Pinning does not allocate by itself. Expected stdout (not executed): 7 Common mistake: Treating Pin as a heap allocator.
Formal Syntax & Structure
rust syntaxrust
use std::pin::Pin;Working Example
Example Snippetrust
fn main() { use std::{marker::PhantomPinned, pin::Pin}; struct Note { value: u32, _pin: PhantomPinned } let note = std::pin::pin!(Note { value: 7, _pin: PhantomPinned }); println!("{}", note.as_ref().get_ref().value);}