strum
Rust procedural macro library for adding useful derive macros to enum types. Provides #[derive(Display, EnumString, EnumIter, EnumCount, EnumVariantNames, EnumMessage, IntoStaticStr, AsRefStr, EnumIs)] and more. Makes Rust enums easy to convert to/from strings, iterate over variants, count variants, and attach messages. Particularly useful for configuration systems, CLI argument parsing, and domain type modeling.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Compile-time macro library. No runtime security surface.
⚡ Reliability
Best When
You need ergonomic string conversion, iteration, or metadata for Rust enums — strum adds the missing standard library enum capabilities.
Avoid When
You need JSON/YAML serialization with custom representations (use serde) or have complex enum variants with data requiring custom Display logic.
Use Cases
- • Convert Rust enum variants to/from strings for configuration files, CLI arguments, and API serialization with #[derive(EnumString, Display)]
- • Iterate over all variants of a Rust enum with #[derive(EnumIter)] for generating menus, help text, or exhaustive testing
- • Attach string messages or documentation to enum variants with #[strum(message)] for user-facing display
- • Build configuration systems where string-to-enum conversion is needed for YAML/TOML config parsing with strum's case-insensitive matching
- • Generate variant names as &'static str for logging and metrics labels without runtime allocation
Not For
- • Complex serialization requirements — use serde for JSON/YAML serialization with custom enum representations
- • Enums with associated data needing Display — strum's Display works best for unit variants; use manual impl for complex data
- • Non-enum types — strum targets enums specifically; use derive_more for struct-level derive macros
Interface
Authentication
Compile-time macro library. No runtime, no authentication.
Pricing
MIT license.
Agent Metadata
Known Gotchas
- ⚠ EnumString matching is case-sensitive by default — use #[strum(ascii_case_insensitive)] for case-insensitive parsing from config files or user input
- ⚠ Display output uses the variant name by default — use #[strum(to_string = "custom")] or #[strum(serialize = "alt")] for custom string representations
- ⚠ EnumIter creates a separate Iter struct — importing MyEnumIter and calling IntoEnumIterator::iter() requires the IntoEnumIterator trait in scope
- ⚠ Variants with associated data (tuple variants, struct variants) may not support all strum derives — check which derives work with data-carrying variants
- ⚠ strum and strum_macros are separate crates — must add both as dependencies; strum_macros provides the proc-macros, strum provides the traits
- ⚠ Rename attributes in strum and serde can conflict — when using both, strum #[strum(serialize)] and serde #[serde(rename)] apply independently
Alternatives
Full Evaluation Report
Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for strum.
AI-powered analysis · PDF + markdown · Delivered within 30 minutes
Package Brief
Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.
Delivered within 10 minutes
Score Monitoring
Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.
Continuous monitoring
Scores are editorial opinions as of 2026-03-07.