comparable constraint

The comparable constraint limits generic type parameters to types that support equality comparison operators like == and !=.

The comparable constraint restricts a type parameter to types that support equality comparison using == and !=. Use it in generic function or type definitions to ensure the type can be compared, such as for map keys or sorting.

func Contains[T comparable](slice []T, item T) bool {
	for _, v := range slice {
		if v == item {
			return true
		}
	}
	return false
}