diff --git a/doc/go_spec.html b/doc/go_spec.html index c653cbffc0274b..69ac1d353fa06d 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -2656,6 +2656,53 @@
+The predeclared
+interface type comparable
+denotes the set of all concrete (non-interface) types that are
+comparable. Specifically,
+a type T
implements comparable
if:
+
T
is not an interface type and T
supports the operations
+ ==
and !=
; or
+T
is an interface type and each type in T
's
+ type set implements comparable
.
+
+Even though interfaces that are not type parameters can be
+compared
+(possibly causing a run-time panic) they do not implement
+comparable
.
+
+int // implements comparable +[]byte // does not implement comparable (slices cannot be compared) +interface{} // does not implement comparable (see above) +interface{ ~int | ~string } // type parameter only: implements comparable +interface{ comparable } // type parameter only: implements comparable +interface{ ~int | ~[]byte } // type parameter only: does not implement comparable (not all types in the type set are comparable) ++ +
+The comparable
interface and interfaces that (directly or indirectly) embed
+comparable
may only be used as type constraints. They cannot be the types of
+values or variables, or components of other, non-interface types.
+