primary

Macro primary 

Source
primary!() { /* proc-macro */ }
Expand description

Define primary enums with automatic PrimaryId trait implementation.

Supports all 6 metadata fields in any order:

  • value - Custom string (default: identifier as-is)
  • description - Documentation string
  • introduced - Version introduced
  • deprecated - Deprecation notice
  • examples - Array of example error codes
  • related - Array of related primary codes

§Examples

primary! {
    Token,                   // Simple: "Token"
    Syntax {                 // With metadata
        description: "Syntax errors",
        related: ["Parse", "Lex"],
    },
}

// Generated code implements PrimaryIdDocumented trait:
let desc = Primary::Syntax.description();  // Trait method
let related = Primary::Syntax.related();