Strum

Derive macros and traits that make Rust enums easier to convert to and from strings

Library
Cargo
v0.28.0
2,465 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
45 /100 Fair
Development Activity 0
Maintenance 20
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
75 /100 Good
Architecture 75
Code Quality 78
Innovation 65
Learning Curve 80

Strum is a Rust library that eliminates the boilerplate of converting enums to and from strings and other representations. Rather than hand-writing match statements for Display, FromStr, or iteration over an enum’s variants, Strum provides derive macros — EnumString, Display, EnumIter, EnumCount, EnumProperty, EnumDiscriminants, VariantNames, and more — that generate this code automatically at compile time.

The project is split into two crates that are typically used together: strum holds the traits consumed by generated code, and strum_macros (importable directly through strum’s derive feature) provides the actual procedural macros. This split keeps the runtime dependency lightweight while all the code-generation logic lives in the macro crate, which is only needed at compile time.

What You Get

  • EnumString/Display derives for parsing enums from strings and formatting them back to strings
  • EnumIter to generate an iterator over all variants of an enum, and EnumCount/VariantArray/VariantNames for variant metadata as constants
  • FromRepr to convert integer discriminants back into enum variants
  • EnumProperty/EnumMessage to attach custom key-value properties or human-readable messages to individual variants via attributes
  • EnumDiscriminants to generate a companion enum containing only the variant names/discriminants, useful for matching without carrying variant data

Common Use Cases

  • Parsing configuration values or CLI arguments into strongly-typed enums via EnumString
  • Rendering enum variants as human-readable strings in logs, error messages, or UI labels via Display
  • Iterating over all possible variants of an enum for validation, test generation, or building selection UIs via EnumIter
  • Attaching metadata like display names or descriptions to enum variants for use in APIs or documentation via EnumProperty/EnumMessage

Under The Hood

Architecture The project is a Cargo workspace split into strum (the small runtime crate exposing the traits that generated code implements, in strum/src/lib.rs) and strum_macros (the procedural macro crate that does all the actual code generation, parsing enum definitions and their attributes with syn to emit trait implementations). This separation means consumers who only need the traits (e.g. for trait objects across a workspace) can depend on strum without pulling in syn/quote at all, while the derive feature flag re-exports the macros from strum_macros for the common case of using both together. A STRUM_DEBUG environment variable lets users dump the generated code for debugging macro output, and strum_tests/strum_nostd_tests provide integration coverage across std and no_std configurations.

Tech Stack Pure Rust, edition 2021, with strum_macros depending on the standard proc-macro toolchain (syn, quote, proc-macro2) while the strum crate itself has zero required dependencies beyond an optional phf for perfect-hash-based string matching and an optional path dependency on strum_macros gated behind the derive feature. The crate explicitly targets a 2-year-plus rustc compatibility window (currently rustc >= 1.71.1).

Code Quality Testing is split across dedicated strum_tests (std) and strum_nostd_tests (no_std) crates that exercise every derive macro’s generated code as integration tests rather than only unit tests within the macro crate — an appropriate structure for a proc-macro library, since the real correctness surface is the code it generates, not the macro implementation in isolation. CI runs via GitHub Actions (ci.yml), and the project has a stated 2-year rustc support policy that signals a deliberate, conservative maintenance stance.

API Design The API surface for consumers is almost entirely declarative: adding #[derive(EnumString, Display, ...)] above an enum, optionally with per-variant #[strum(...)] attributes for customization (renaming, serialization strings, properties). This keeps boilerplate to a single derive line per desired behavior, though understanding the full space of #[strum(...)] attribute options requires consulting the docs, since attribute-driven APIs are inherently less discoverable via autocomplete than method-based ones.

Used by 18 apps in this directory

Rust
71%
MIT

monty

AI Development · Developer Tools

8,763

Run LLM-generated Python code safely inside your agent—no containers, no CPython, no compromise—with sub-microsecond startup.

View details
88
Repo Health
83
Technical
73
Dependency
Built with
Rust 71%
Python 24%
Updated 1 weeks ago
Rust
85%
AGPL 3.0

ParadeDB

Analytics · Databases · Search

9,436

Born out of Y Combinator's S2023 batch, ParadeDB is a Postgres extension that delivers Elasticsearch-quality BM25 search and real-time analytics without a separate search cluster to manage.

View details
89
Repo Health
87
Technical
68
Dependency
Built with
Rust 85%
PLpgSQL 15%
Updated 6 days ago
Rust
85%
AGPL 3.0

ParadeDB

Analytics · Databases · Search

9,436

Born out of Y Combinator's S2023 batch, ParadeDB is a Postgres extension that delivers Elasticsearch-quality BM25 search and real-time analytics without a separate search cluster to manage.

View details
89
Repo Health
87
Technical
68
Dependency
Built with
Rust 85%
PLpgSQL 15%
Updated 6 days ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

40,397

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 6 days ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

40,397

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 6 days ago
Rust
79%
AGPL 3.0

Spacedrive

Collaboration · File Storage

39,292

One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.

View details
84
Repo Health
84
Technical
63
Dependency
Built with
Rust 79%
TypeScript 18%
Updated 2 weeks ago
Rust
79%
Apache 2.0

TensorZero

Ab Testing Experimentation · AI Development · Monitoring

11,708

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
68
Dependency
Built with
Rust 79%
TypeScript 15%
Updated 4 months ago
Rust
50%
Apache 2.0

Vibe Kanban

AI Agents · AI Code Assistants · Project Management

28,441

A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.

View details
72
Repo Health
75
Technical
63
Dependency
Built with
Rust 50%
TypeScript 46%
Updated 1 months ago
Rust
50%
Apache 2.0

Vibe Kanban

AI Agents · AI Code Assistants · Project Management

28,441

A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.

View details
72
Repo Health
75
Technical
63
Dependency
Built with
Rust 50%
TypeScript 46%
Updated 1 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