PhantomPinned

Definition

// Copyright 2026 Google LLC
// SPDX-License-Identifier: Apache-2.0

pub struct PhantomPinned;

impl !Unpin for PhantomPinned {}

Usage

// Copyright 2026 Google LLC
// SPDX-License-Identifier: Apache-2.0

pub struct DynamicBuffer {
    data: Vec<u8>,
    cursor: std::ptr::NonNull<u8>,
    _pin: std::marker::PhantomPinned,
}
This slide should take about 5 minutes.

PhantomPinned is a marker type.

If a type contains a PhantomPinned, it will not implement Unpin by default.

This has the effect of enforcing pinning when DynamicBuffer is wrapped by Pin.