Skip to content

Commit 85ff5d8

Browse files
committed
On Go 1.21+, use cmp.Ordered instead of a private type
Go 1.21 introduces a language-maintained constraint permitting any ordered types, use that instead of the private version defined in sets. Signed-off-by: Stephen Kitt <[email protected]>
1 parent 49e7df5 commit 85ff5d8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

set/ordered.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !go1.21
2+
13
/*
24
Copyright 2023 The Kubernetes Authors.
35

set/ordered_go1.21.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//go:build go1.21
2+
3+
/*
4+
Copyright 2023 The Kubernetes Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package set
20+
21+
import "cmp"
22+
23+
// ordered is a constraint that permits any ordered type: any type
24+
// that supports the operators < <= >= >.
25+
// If future releases of Go add new ordered types,
26+
// this constraint will be modified to include them.
27+
type ordered = cmp.Ordered

0 commit comments

Comments
 (0)