Hi there, Thanks to Go generics in 1.18, I can write a generic function `LenBetween` for a slice:
```go func SliceLenBetween[T ~[]E, E any](s T, min, max int) bool { return len(s) >= min && len(s) <= max } ``` as well as for a map: ```go func MapLenBetween[T map[K]V, K comparable, V any](s T, min, max int) bool { return len(s) >= min && len(s) <= max } ``` Is there any way to write a constraint, say, SliceOrMap, to support either a slice or a map? With the help of SliceOrMap, then I can write a more generic version `LenBetween` like this: ```go func MapLenBetween[T SliceOrMap](s T, min, max int) bool { return len(s) >= min && len(s) <= max } ``` Thanks in advance! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/450b8476-d52f-4a5d-9dd3-6db69049309en%40googlegroups.com.