darling

Parse attributes into structs when writing custom Rust derive macros

Library
Cargo
v0.24.0
1,266stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
67/100Good
Development Activity52
Maintenance60
Community56
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture83
Code Quality85
Innovation80
Learning Curve72

darling is a Rust crate for proc-macro authors that turns attribute parsing into a declarative, serde-like experience. Instead of hand-writing token inspection, macro authors annotate a struct and let darling read #[...] attributes into it, complete with validation and high-quality error messages.

Heavily inspired by serde in both API and internals, darling dramatically reduces the boilerplate and edge cases involved in writing robust custom derives, so proc-macros can be highly configurable with minimal effort.

What You Get

  • Declarative parsing of attributes into typed structs via derive macros
  • Automatic validation with clear, spanned error messages
  • serde-inspired API that is familiar to Rust developers
  • Support for nested attributes, defaults, and custom conversions
  • Optional suggestions and diagnostics features for better UX

Common Use Cases

  • Writing custom derive macros that accept configuration attributes
  • Building attribute-driven code generators with minimal boilerplate
  • Validating proc-macro input and surfacing helpful compiler errors
  • Sharing attribute-parsing logic across a family of derive macros

Under The Hood

Architecture — darling is a Cargo workspace split into three crates: darling_core (the parsing engine and error types), darling_macro (the procedural derive implementations), and the top-level darling facade that re-exports them, so downstream users depend on a single crate. Tech Stack — Rust edition 2021 (MSRV 1.88) built on syn, quote, and proc-macro2, the standard proc-macro toolchain, with trybuild and rustversion driving compile-time tests. Code Quality — The project is mature and well-tested, with a tests/ suite, compile-fail tests via trybuild, examples, a detailed CHANGELOG, and clippy/rustfmt configuration. API Design — The derive-based API closely mirrors serde’s Deserialize, so authors declare a struct and derive FromDeriveInput/FromMeta; this makes common cases nearly free while advanced customization is available through trait implementations.

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