<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/what-is-std-pin-pin-in-rust--sewemh0rx" -->

---
title: What is std::pin::Pin in Rust? | daily.dev
description: A deep dive into `std::pin::Pin` in Rust, explaining why it exists and how it works. Self-referential structs create dangling pointer risks when moved, and...
canonical: https://daily.dev/posts/what-is-std-pin-pin-in-rust--sewemh0rx
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: What is std::pin::Pin in Rust? | daily.dev
og:description: A deep dive into `std::pin::Pin` in Rust, explaining why it exists and how it works. Self-referential structs create dangling pointer risks when moved, and...
og:url: https://daily.dev/posts/what-is-std-pin-pin-in-rust--sewemh0rx
og:image: https://api.daily.dev/og/posts/sewEMH0rX.png
og:image:alt: What is std::pin::Pin in Rust?
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# What is std::pin::Pin in Rust?

**[Lobsters](https://daily.dev/sources/lobsters)** · 7 min read · 3 upvotes · 0 comments

## Summary

A deep dive into `std::pin::Pin` in Rust, explaining why it exists and how it works. Self-referential structs create dangling pointer risks when moved, and async/await futures are the most common real-world case — the compiler-generated state machine can become self-referential across `.await` points. `Pin<P>` is a pointer wrapper that prevents safe code from moving the pointee, while `Unpin` marks types that are safe to move regardless. The post covers how to construct pins using `Pin::new` (for `Unpin` types), the `pin!` macro (stack pinning), `Box::pin` (heap pinning), and `Pin::new_unchecked` (unsafe). `PhantomPinned` is the standard way to opt a struct out of `Unpin`. Most developers only encounter `Pin` when manually polling futures or implementing custom async primitives.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://vrong.me/blog/what-is-pinning-in-rust>

## Similar posts on daily.dev

- [Async Rust: Pinning demystified](https://daily.dev/posts/async-rust-pinning-demystified-rfgkmdeya) · The New Stack · 2 upvotes · 0 comments
- [The Algebra of Loans in Rust](https://daily.dev/posts/the-algebra-of-loans-in-rust-zcqh92rn8) · Hacker News · 19 upvotes · 7 comments

---

Tags: [#rust](https://daily.dev/tags/rust)

[View this post on daily.dev](https://daily.dev/posts/what-is-std-pin-pin-in-rust--sewemh0rx)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"What is std::pin::Pin in Rust?","url":"https://daily.dev/posts/what-is-std-pin-pin-in-rust--sewemh0rx","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/what-is-std-pin-pin-in-rust--sewemh0rx"},"datePublished":"2026-06-30T06:01:09.565Z","dateModified":"2026-06-30T06:01:33.513Z","description":"A deep dive into `std::pin::Pin` in Rust, explaining why it exists and how it works. Self-referential structs create dangling pointer risks when moved, and...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a647bc3e2c902069107182512f6734f6?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a647bc3e2c902069107182512f6734f6?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Lobsters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Lobsters","logo":"https://media.daily.dev/image/upload/s--tl8v_Fku--/f_auto,t_logo/v1698841318/logos/lobste.jpg","url":"https://daily.dev/sources/lobsters"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/what-is-std-pin-pin-in-rust--sewemh0rx","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"rust","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Lobsters","item":"https://daily.dev/sources/lobsters"},{"@type":"ListItem","position":3,"name":"What is std::pin::Pin in Rust?"}]}
```

