---
source: https://iinventedlight.com/library/notes/rust-pin.md
title: "Pin a Rust future so it cannot be moved in memory"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (The Rust Programming Language); MIT OR Apache-2.0 (Rust standard library); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: The Rust Programming Language, A Closer Look at the Traits for Async; Rust standard library, Module pin. MIT OR Apache-2.0; MIT OR Apache-2.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: Rust Pin and Unpin for async futures"
tags: [rust, pin, unpin, async, futures]
client: Librarian
sources:
  - id: S1
    title: "A Closer Look at the Traits for Async"
    publisher: The Rust Programming Language
    url: https://doc.rust-lang.org/book/ch17-05-traits-for-async.html
    accessed: 2026-11-19
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Module pin"
    publisher: Rust standard library
    url: https://doc.rust-lang.org/std/pin/index.html
    accessed: 2026-11-19
    license: "MIT OR Apache-2.0"
---
# Pin a Rust future so it cannot be moved in memory
**Answer:** Pin is a type that guarantees the values won't be moved in memory. The standard pin module describes types that pin data to a location in memory. Future::poll takes self as Pin<&mut Self>.

## Pin and Unpin

You will need the Pin type and the Unpin trait when you dig into Future. poll is declared as a method that takes Pin<&mut Self>. If dyn Future cannot be unpinned, consider using the pin! macro, or consider using Box::pin if you need to also access the pinned value outside of the current scope.

The pin module is about types that pin data to a location in memory. It is sometimes useful to rely upon a certain value not being able to move, meaning its address in memory cannot change. This is useful especially when also there are one or more pointers pointing at that value. Pinning is necessary to implement safe interfaces on top of things like self-referential types. A type may implement Unpin.

| Pin | Unpin |
|---|---|
| Pin | Type that guarantees values won't be moved in memory |
| Unpin | Trait for types that may be moved after pinning |
| pin! | Macro that pins a value in the current scope |
| Box::pin | Pins a value when you need it outside the current scope |
| poll | Future method that takes Pin<&mut Self> |

## See also

- [rust-async-await-futures](https://iinventedlight.com/library/notes/rust-async-await-futures/)
- [rust-box-and-deref](https://iinventedlight.com/library/notes/rust-box-and-deref/)
- [rust-ownership-borrowing](https://iinventedlight.com/library/notes/rust-ownership-borrowing/)

## Claims

- id: C1
  claim: Pin guarantees that values will not be moved in memory.
  source: S1
  evidence: "guarantees the values won't be moved in memory"

- id: C2
  claim: Future::poll takes self as Pin of a mutable reference.
  source: S1
  evidence: "fn poll(self: Pin<&mut Self>, cx: &mut Context"

- id: C3
  claim: The pin module covers types that pin data to a location in memory.
  source: S2
  evidence: "Types that pin data to a location in memory"

## Sources

- [S1] A Closer Look at the Traits for Async. The Rust Programming Language. https://doc.rust-lang.org/book/ch17-05-traits-for-async.html . License: MIT OR Apache-2.0. Accessed 2026-11-19.

- [S2] Module pin. Rust standard library. https://doc.rust-lang.org/std/pin/index.html . License: MIT OR Apache-2.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Rust Programming Language, A Closer Look at the Traits for Async; Rust standard library, Module pin. MIT OR Apache-2.0; MIT OR Apache-2.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
