pin-project

Safe, ergonomic pin projection for Rust structs and enums

Library
Cargo
v1.1.13
717stars
Apache-2.0 OR MIT

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
73/100Good
Development Activity72
Maintenance80
Community52
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture86
Code Quality88
Innovation80
Learning Curve68

pin-project generates safe projection types for Pin<&mut Self> fields via a #[pin_project] attribute macro, so authors of hand-written Future/Stream/AsyncRead implementations don’t have to write unsafe code to access pinned fields. Marking a field #[pin] produces a .project() method returning Pin<&mut T> for pinned fields and plain &mut T for the rest, matching exactly what the borrow checker needs.

It’s the de facto standard for pin projection in the Rust async ecosystem, used directly or transitively by a huge share of futures/stream-combinator crates; a lighter-weight sibling, pin-project-lite, trades some ergonomics for a declarative-macro-only implementation with no proc-macro compile-time cost.

What You Get

  • A #[pin_project] attribute macro that generates safe projection types for structs and enums
  • Per-field #[pin] markers controlling which fields need pinned access
  • Named enum projections via #[pin_project(project = EnumProj)] for pattern-matching on pinned enum variants
  • #[project_replace] support for Drop-aware in-place field replacement
  • no_std and no_alloc compatibility for embedded/constrained async runtimes

Common Use Cases

  • Implementing a custom Future or Stream by hand that wraps an inner pinned future
  • Writing AsyncRead/AsyncWrite adapters that need pinned access to an inner reader/writer
  • Building async combinator types (map, then, select) where some fields must stay pinned across poll calls
  • Avoiding manual unsafe impl Unpin bookkeeping when only some struct fields are self-referential

Under The Hood

Architecture: The public crate (src/lib.rs, 352 lines) is a documentation/re-export shim over the actual proc-macro implementation in the sibling pin-project-internal crate, which parses the annotated struct/enum and emits a projection type plus the .project()/.project_ref() methods along with the compiler-checked unsafe impl<...> Unpin for ... bounds needed to make the projection sound.

Tech Stack: Pure Rust, no_std/no_alloc compatible (categories include no-std, no-std::no-alloc in Cargo.toml), dual-licensed Apache-2.0/MIT, maintained by taiki-e who owns a large share of foundational async/no_std Rust tooling (also pin-project-lite, cargo-hack).

Code Quality: 140+ test files under tests/ cover struct/enum projection, Drop interaction, !Unpin edge cases, and macro-expansion snapshots, with examples/*-expanded.rs files showing exactly what code the macro generates for auditability — an important property for a crate whose entire value proposition is proving generated unsafe code is sound.

API Design: The core API is two annotations (#[pin_project] on the type, #[pin] on individual fields) plus a generated .project() call — deliberately mirroring how you’d naturally reason about which fields need pinning, with enum support requiring only one extra project = Name argument, keeping the mental model close to plain Rust pattern matching.

Used by 9 apps in this directory

Dart
74%
AGPL 3.0

AppFlowy

Productivity · Project Management · Collaboration

75,729

The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.

View details
66
Repo Health
81
Technical
66
Dependency
Built with
Dart74%
Rust24%
Updated 1 weeks ago
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,761

Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.

View details
90
Repo Health
86
Technical
67
Dependency
Built with
TypeScript75%
Updated today
Rust
96%
Apache 2.0

InfluxDB

Databases · Analytics

31,705

Open-source time-series database built for real-time ingest, fast SQL queries, and embedded Python automation — powered by Apache Arrow and Parquet.

View details
86
Repo Health
76
Technical
72
Dependency
Built with
Rust96%
Updated yesterday
Rust
36%
Apache 2.0

LanceDB

Databases · AI Development

11,190

Open-source, embedded vector database built on the Lance columnar format for fast multimodal search across billions of vectors, backed by Y Combinator (W23).

View details
90
Repo Health
86
Technical
72
Dependency
Built with
Rust36%
HTML30%
Python26%
Updated today
TypeScript
95%
MIT

melty

Developer Tools · AI Code Assistants · Code Editors

5,449

The AI code editor where every chat message is a git commit you can revert, branch, or squash

View details
35
Repo Health
75
Technical
68
Dependency
Built with
TypeScript95%
Updated 1 years ago
Python
55%
Other

PostHog

Analytics · Monitoring · Developer Tools

37,777

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
67
Dependency
Built with
Python55%
TypeScript36%
Updated today
Rust
93%
Other

Tabby

AI Code Assistants

33,828

Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.

View details
61
Repo Health
78
Technical
63
Dependency
Built with
Rust93%
Updated 1 months ago
TypeScript
95%
Apache 2.0

Void

AI Code Assistants · Code Editors · Automation

28,833

Open-source AI code editor with direct LLM integration and data privacy

View details
49
Repo Health
84
Technical
69
Dependency
Built with
TypeScript95%
Updated 2 months ago
Rust
97%
Other

Zed

Developer Tools · Collaboration · Code Editors

88,861

High-performance, multiplayer code editor built in Rust by the creators of Atom and Tree-sitter, with native AI integration and real-time collaboration.

View details
94
Repo Health
88
Technical
73
Dependency
Built with
Rust97%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search