Strum

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

Library
Cargo
v0.28.0
2,423stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
47/100Fair
Development Activity8
Maintenance20
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture75
Code Quality78
Innovation65
Learning Curve80

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 12 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
55%
Other

Cap

Team Chat · Video Conferencing

20,986

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
65
Dependency
Built with
TypeScript55%
Rust40%
Updated yesterday
Rust
95%
MIT

Fyrox

Game Development

9,512

A production-ready 2D/3D game engine written in Rust with a built-in scene editor, physics, and hot-reloading game scripts

View details
85
Repo Health
79
Technical
68
Dependency
Built with
Rust95%
Updated yesterday
Rust
69%
Other

GitButler

Developer Tools · Devops · AI Development

21,531

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
68
Dependency
Built with
Rust69%
TypeScript18%
Svelte12%
Updated today
Rust
41%
Other

Hook0

Devops

1,477

Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.

View details
83
Repo Health
82
Technical
70
Dependency
Built with
Rust41%
TypeScript17%
JavaScript15%
Updated today
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,055

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago
TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,384

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
64
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
Rust
72%
MIT

monty

AI Development · Developer Tools

8,079

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

View details
87
Repo Health
83
Technical
73
Dependency
Built with
Rust72%
Python23%
Updated yesterday
Rust
87%
AGPL 3.0

ParadeDB

Search · Databases · Analytics

9,175

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
88
Repo Health
87
Technical
71
Dependency
Built with
Rust87%
PLpgSQL12%
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