Skip to content

Conversation

@Turbo87
Copy link

@Turbo87 Turbo87 commented Nov 8, 2025

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

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 iliekturtles#539
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Are unit structs necessary in Units enums?

1 participant