From: Cuong Manh Le Date: Fri, 26 May 2023 04:12:12 +0000 (+0700) Subject: builtin: add documentation for min/max X-Git-Tag: go1.21rc1~107 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2f5e2f6cc12b4f654b96d6ac6da80cd693e33fc4;p=gostls13.git builtin: add documentation for min/max Updates #59488 Change-Id: If873b81fb7f0e28b84a3e5c2ff89426b3e289d5d Reviewed-on: https://go-review.googlesource.com/c/go/+/498495 TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Auto-Submit: Cuong Manh Le Reviewed-by: Matthew Dempsky Run-TryBot: Cuong Manh Le --- diff --git a/src/builtin/builtin.go b/src/builtin/builtin.go index bcfb7ce956..03e90c8a56 100644 --- a/src/builtin/builtin.go +++ b/src/builtin/builtin.go @@ -10,6 +10,8 @@ for the language's special identifiers. */ package builtin +import "cmp" + // bool is the set of boolean values, true and false. type bool bool @@ -206,6 +208,14 @@ func cap(v Type) int // unbuffered. func make(t Type, size ...IntegerType) Type +// The max built-in function returns the largest value of a fixed number of +// arguments of [cmp.Ordered] types. There must be at least one argument. +func max[T cmp.Ordered](x T, y ...T) T + +// The min built-in function returns the smallest value of a fixed number of +// arguments of [cmp.Ordered] types. There must be at least one argument. +func min[T cmp.Ordered](x T, y ...T) T + // The new built-in function allocates memory. The first argument is a type, // not a value, and the value returned is a pointer to a newly // allocated zero value of that type.