PhantomPinned

定義

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

pub struct PhantomPinned;

impl !Unpin for PhantomPinned {}

使用法

// 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,
}

PhantomPinned はマーカー型です。

型が PhantomPinned を含んでいる場合、その型はデフォルトでは Unpin を実装しません。

これにより、DynamicBufferPin でラップされると、ピン留めが強制されます。