From 952b677bf7f10da93673e3671f764c54c454bbfe Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 13 Jul 2022 20:41:10 -0600 Subject: Move ordered.go to lib/containers Something about this trips a stack overflow in golangci-lint, so upgrade golangci-lint to a commit that fixes this. --- lib/util/ordered.go | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 lib/util/ordered.go (limited to 'lib/util') diff --git a/lib/util/ordered.go b/lib/util/ordered.go deleted file mode 100644 index fc5b5ee..0000000 --- a/lib/util/ordered.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2022 Luke Shumaker -// -// SPDX-License-Identifier: GPL-2.0-or-later - -package util - -import ( - "golang.org/x/exp/constraints" -) - -func CmpUint[T constraints.Unsigned](a, b T) int { - switch { - case a < b: - return -1 - case a == b: - return 0 - default: - return 1 - } -} - -type Ordered[T interface{ Cmp(T) int }] interface { - Cmp(T) int -} - -type NativeOrdered[T constraints.Ordered] struct { - Val T -} - -func (a NativeOrdered[T]) Cmp(b NativeOrdered[T]) int { - switch { - case a.Val < b.Val: - return -1 - case a.Val > b.Val: - return 1 - default: - return 0 - } -} - -var _ Ordered[NativeOrdered[int]] = NativeOrdered[int]{} -- cgit v1.2.3-2-g168b