Documentation
¶
Overview ¶
Package enum provides utilities for implementing exhaustive enumerations.
Index ¶
- func AssignResult[T, R any](fn func(T) R, result *R) func(T)
- func AssignResultErr[T, R any](fn func(T) (R, error), result *R, err *error) func(T)
- func Map[E Enum, T any](v E, cases ...T) T
- func Range[E Enum](begin, end E) iter.Seq[E]
- func String[E Enum](v E, cases ...string) string
- func Switch[E Enum](v E, cases ...func())
- type Enum
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignResult ¶
func AssignResult[T, R any]( fn func(T) R, result *R, ) func(T)
AssignResult returns a function that invokes fn and assigns the result to *result.
func AssignResultErr ¶
AssignResultErr returns a function that invokes fn and assigns the result and error value to *result and *err, respectively.
func String ¶
String is a convenience method for implementing fmt.Stringer. It is similar to Map, but does not panic if the enum value is invalid, and does not recurse into v.String().
Types ¶
Click to show internal directories.
Click to hide internal directories.