From 28536eb2e05130df3784f01f7b78d914a4c02b85 Mon Sep 17 00:00:00 2001 From: surdeus Date: Mon, 28 Nov 2022 00:16:20 +0500 Subject: [PATCH] Added convs. --- src/slicex/main.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/slicex/main.go b/src/slicex/main.go index 369f9b6..a0daa8d 100644 --- a/src/slicex/main.go +++ b/src/slicex/main.go @@ -14,3 +14,22 @@ func MakeMap[K comparable, V any]( return r } + +func ConvStr[V1, V2 ~string](v1 []V1) []V2 { + ret := []V2{} + for i := range v1 { + ret = append(ret, V2(v1[i])) + } + + return ret +} + +func ConvInt[V1, V2 ~int](v1 []V1) []V2 { + ret := []V2{} + for i := range v1 { + ret = append(ret, V2(v1[i])) + } + + return ret +} +