From 45df9bf319d38db916ca983b8c92bb912f5ce9ee Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 8 Feb 2023 17:50:10 +0100 Subject: intermediate commit --- go/utils/slices.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'go/utils') diff --git a/go/utils/slices.go b/go/utils/slices.go index d2bc04c1..3cc38c1c 100644 --- a/go/utils/slices.go +++ b/go/utils/slices.go @@ -7,3 +7,11 @@ func TypedSliceToInterfaceSlice[T any](s []T) []interface{} { } return is } + +func InterfaceSliceToTypedSlice[T any](s []interface{}) []T { + ts := make([]T, 0, len(s)) + for _, t := range s { + ts = append(ts, t.(T)) + } + return ts +} -- cgit v1.2.3