mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-09 07:02:29 +08:00
24 lines
861 B
Go
24 lines
861 B
Go
// Copyright 2021 dudaodong@gmail.com. All rights reserved.
|
|
// Use of this source code is governed by MIT license
|
|
|
|
// Package lancetconstraints contain some comstomer constraints.
|
|
package lancetconstraints
|
|
|
|
// Comparator is for comparing two values
|
|
type Comparator interface {
|
|
// Compare v1 and v2
|
|
// Ascending order: should return 1 -> v1 > v2, 0 -> v1 = v2, -1 -> v1 < v2
|
|
// Descending order: should return 1 -> v1 < v2, 0 -> v1 = v2, -1 -> v1 > v2
|
|
Compare(v1, v2 any) int
|
|
}
|
|
|
|
// Number contains all types of number and uintptr, used for generics constraint
|
|
type Number interface {
|
|
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64
|
|
}
|
|
|
|
// Ordered is a constraint that permits any ordered type: any type that supports the operators < <= >= >
|
|
type Ordered interface {
|
|
Number | ~string
|
|
}
|