summaryrefslogtreecommitdiff
path: root/vendor/github.com/samber/lo/internal
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/samber/lo/internal')
-rw-r--r--vendor/github.com/samber/lo/internal/constraints/constraints.go42
-rw-r--r--vendor/github.com/samber/lo/internal/constraints/ordered_go118.go11
-rw-r--r--vendor/github.com/samber/lo/internal/constraints/ordered_go121.go9
-rw-r--r--vendor/github.com/samber/lo/internal/rand/ordered_go118.go26
-rw-r--r--vendor/github.com/samber/lo/internal/rand/ordered_go122.go17
5 files changed, 105 insertions, 0 deletions
diff --git a/vendor/github.com/samber/lo/internal/constraints/constraints.go b/vendor/github.com/samber/lo/internal/constraints/constraints.go
new file mode 100644
index 00000000..3eb1cda5
--- /dev/null
+++ b/vendor/github.com/samber/lo/internal/constraints/constraints.go
@@ -0,0 +1,42 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package constraints defines a set of useful constraints to be used
+// with type parameters.
+package constraints
+
+// Signed is a constraint that permits any signed integer type.
+// If future releases of Go add new predeclared signed integer types,
+// this constraint will be modified to include them.
+type Signed interface {
+ ~int | ~int8 | ~int16 | ~int32 | ~int64
+}
+
+// Unsigned is a constraint that permits any unsigned integer type.
+// If future releases of Go add new predeclared unsigned integer types,
+// this constraint will be modified to include them.
+type Unsigned interface {
+ ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
+}
+
+// Integer is a constraint that permits any integer type.
+// If future releases of Go add new predeclared integer types,
+// this constraint will be modified to include them.
+type Integer interface {
+ Signed | Unsigned
+}
+
+// Float is a constraint that permits any floating-point type.
+// If future releases of Go add new predeclared floating-point types,
+// this constraint will be modified to include them.
+type Float interface {
+ ~float32 | ~float64
+}
+
+// Complex is a constraint that permits any complex numeric type.
+// If future releases of Go add new predeclared complex numeric types,
+// this constraint will be modified to include them.
+type Complex interface {
+ ~complex64 | ~complex128
+}
diff --git a/vendor/github.com/samber/lo/internal/constraints/ordered_go118.go b/vendor/github.com/samber/lo/internal/constraints/ordered_go118.go
new file mode 100644
index 00000000..a124366f
--- /dev/null
+++ b/vendor/github.com/samber/lo/internal/constraints/ordered_go118.go
@@ -0,0 +1,11 @@
+//go:build !go1.21
+
+package constraints
+
+// Ordered is a constraint that permits any ordered type: any type
+// that supports the operators < <= >= >.
+// If future releases of Go add new ordered types,
+// this constraint will be modified to include them.
+type Ordered interface {
+ Integer | Float | ~string
+}
diff --git a/vendor/github.com/samber/lo/internal/constraints/ordered_go121.go b/vendor/github.com/samber/lo/internal/constraints/ordered_go121.go
new file mode 100644
index 00000000..c02de935
--- /dev/null
+++ b/vendor/github.com/samber/lo/internal/constraints/ordered_go121.go
@@ -0,0 +1,9 @@
+//go:build go1.21
+
+package constraints
+
+import (
+ "cmp"
+)
+
+type Ordered = cmp.Ordered
diff --git a/vendor/github.com/samber/lo/internal/rand/ordered_go118.go b/vendor/github.com/samber/lo/internal/rand/ordered_go118.go
new file mode 100644
index 00000000..9fbc5385
--- /dev/null
+++ b/vendor/github.com/samber/lo/internal/rand/ordered_go118.go
@@ -0,0 +1,26 @@
+//go:build !go1.22
+
+package rand
+
+import "math/rand"
+
+func Shuffle(n int, swap func(i, j int)) {
+ rand.Shuffle(n, swap)
+}
+
+func IntN(n int) int {
+ // bearer:disable go_gosec_crypto_weak_random
+ return rand.Intn(n)
+}
+
+func Int64() int64 {
+ // bearer:disable go_gosec_crypto_weak_random
+ n := rand.Int63()
+
+ // bearer:disable go_gosec_crypto_weak_random
+ if rand.Intn(2) == 0 {
+ return -n
+ }
+
+ return n
+}
diff --git a/vendor/github.com/samber/lo/internal/rand/ordered_go122.go b/vendor/github.com/samber/lo/internal/rand/ordered_go122.go
new file mode 100644
index 00000000..65abf51a
--- /dev/null
+++ b/vendor/github.com/samber/lo/internal/rand/ordered_go122.go
@@ -0,0 +1,17 @@
+//go:build go1.22
+
+package rand
+
+import "math/rand/v2"
+
+func Shuffle(n int, swap func(i, j int)) {
+ rand.Shuffle(n, swap)
+}
+
+func IntN(n int) int {
+ return rand.IntN(n)
+}
+
+func Int64() int64 {
+ return rand.Int64()
+}