From b784f0b2728be2ffae2d852b94581d9b32fb9beb Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Sat, 9 Apr 2022 17:36:14 +0200 Subject: [PATCH] Export BinopTypeSwitch helper for external binops --- operator.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/operator.go b/operator.go index 1e072b8a..0c1f57bb 100644 --- a/operator.go +++ b/operator.go @@ -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,