uom icon indicating copy to clipboard operation
uom copied to clipboard

Remove unnecessary unit struct fields from `Units` enum variants

Open Turbo87 opened this issue 2 months ago • 0 comments

The unit struct fields in Units enum variants were never accessed - they were only used for construction and immediately discarded in pattern matching.

Changes:

  • Convert tuple-like enum variants (e.g., steradian(steradian)) to unit-like variants (e.g., steradian)
  • Update pattern matching to use simpler syntax without wildcards
  • Update ALL_UNITS initialization to use unit-like syntax
  • Update tests to construct enum variants without passing unit structs

Benefits:

  • Simpler, clearer API
  • Smaller enum variants (no tuple wrapper)
  • Less confusion about unused fields

Breaking change: External code constructing Units enum variants must use unit-like syntax instead of tuple-like syntax.

Fixes #539

Turbo87 avatar Nov 08 '25 12:11 Turbo87