Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enum.Builder #7

Merged
merged 1 commit into from
Sep 3, 2023
Merged

Add enum.Builder #7

merged 1 commit into from
Sep 3, 2023

Conversation

orsinium
Copy link
Member

Add enum.Builder which can be used to construct a new enum:

type Color enum.Member[string]

var (
  b      = enum.NewBuilder[string, Color]()
  Red    = b.Add(Color{"red"})
  Green  = b.Add(Color{"green"})
  Blue   = b.Add(Color{"blue"})
  Colors = b.Enum()
)

The goal is to prevent situations when the enum may evolve as the project grows and people might forget to add new members to the enum.

I'll leave the PR open so you folks can leave your comments. Do you find it useful? Do you have ideas on how to make it better?

@orsinium
Copy link
Member Author

orsinium commented Sep 3, 2023

Let's do this!

@orsinium orsinium merged commit b7aa223 into master Sep 3, 2023
6 checks passed
@orsinium orsinium deleted the builder branch September 3, 2023 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant