Skip to content

Commit

Permalink
Export BinopTypeSwitch helper for external binops
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Jan 1, 2024
1 parent f65497d commit b784f0b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,29 @@ func (op *Operator) UnmarshalJSON(text []byte) error {
return nil
}

// BinopTypeSwitch helper for external binops
// re-exported instead of renamed to make it easier to follow upstream
func BinopTypeSwitch(
l, r any,
callbackInts func(_, _ int) any,
callbackFloats func(_, _ float64) any,
callbackBigInts func(_, _ *big.Int) any,
callbackStrings func(_, _ string) any,
callbackArrays func(_, _ []any) any,
callbackMaps func(_, _ map[string]any) any,
fallback func(_, _ any) any) any {
return binopTypeSwitch(
l, r,
callbackInts,
callbackFloats,
callbackBigInts,
callbackStrings,
callbackArrays,
callbackMaps,
fallback,
)
}

func binopTypeSwitch(
l, r any,
callbackInts func(_, _ int) any,
Expand Down

0 comments on commit b784f0b

Please sign in to comment.