pin-project

Safe, ergonomic pin projection for Rust structs and enums

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
74 /100 Good
Development Activity 80
Maintenance 76
Community 52
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
81 /100 Excellent
Architecture 86
Code Quality 88
Innovation 80
Learning Curve 68

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 10 apps in this directory

Dart
74%
AGPL 3.0

AppFlowy

AI Assistants · Collaboration · Productivity

76,967

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
67
Dependency
Built with
Dart 74%
Rust 24%
Updated 1 weeks ago
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,787

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
66
Dependency
Built with
TypeScript 75%
Updated 4 days ago
Rust
96%
Apache 2.0

InfluxDB

Analytics · Databases

31,758

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
82
Repo Health
76
Technical
72
Dependency
Built with
Rust 96%
Updated 1 weeks ago
Rust
43%
Apache 2.0

LanceDB

AI Development · Databases

11,544

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
71
Dependency
Built with
Rust 43%
Python 25%
HTML 23%
Updated 5 days ago
TypeScript
95%
MIT

melty

AI Code Assistants · Code Editors · Developer Tools

5,444

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
67
Dependency
Built with
TypeScript 95%
Updated 1 years ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

39,975

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
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 4 days ago
Rust
93%
Other

Tabby

AI Code Assistants

33,892

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

View details
58
Repo Health
78
Technical
61
Dependency
Built with
Rust 93%
Updated 3 months ago
Rust
79%
Apache 2.0

TensorZero

Ab Testing Experimentation · AI Development · Monitoring

11,717

TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.

View details
53
Repo Health
87
Technical
69
Dependency
Built with
Rust 79%
TypeScript 15%
Updated 3 months ago
TypeScript
95%
Apache 2.0

Void

AI Code Assistants · Automation · Code Editors

28,786

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

View details
45
Repo Health
84
Technical
68
Dependency
Built with
TypeScript 95%
Updated 4 months ago

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