Skip to content

Commit

Permalink
back-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
huykingsofm committed Dec 18, 2024
1 parent a910c72 commit 8a2f401
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions wrap_int_enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"

"github.com/xybor-x/enum/internal/core"
"github.com/xybor-x/enum/internal/mtkey"
"github.com/xybor-x/enum/internal/mtmap"
)

// WrapEnum provides a set of built-in methods to simplify working with int
Expand All @@ -31,6 +33,14 @@ func (e *WrapEnum[underlyingEnum]) Scan(a any) error {
return ScanSQL(a, e)
}

// Int returns the int representation of the enum. This method returns the value
// of math.MinInt32 if the enum is invalid.
//
// DEPRECATED: directly cast the enum to int instead.
func (e WrapEnum[underlyingEnum]) Int() int {
return mtmap.Get(mtkey.Enum2Number[WrapEnum[underlyingEnum], int](e))
}

func (e WrapEnum[underlyingEnum]) String() string {
return ToString(e)
}
Expand Down

0 comments on commit 8a2f401

Please sign in to comment.