Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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,
}
This slide should take about 5 minutes.

PhantomPinned — маркерный тип.

Если тип содержит PhantomPinned, по умолчанию он не реализует Unpin.

Это обеспечивает pinning, когда DynamicBuffer обёрнут в Pin.