aboutsummaryrefslogtreecommitdiff
path: root/is/comparable.go
diff options
context:
space:
mode:
Diffstat (limited to 'is/comparable.go')
-rw-r--r--is/comparable.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/is/comparable.go b/is/comparable.go
new file mode 100644
index 0000000..7d639d8
--- /dev/null
+++ b/is/comparable.go
@@ -0,0 +1,18 @@
+// SPDX-FileCopyrightText: 2025 Stefan Majewsky <majewsky@gmx.net>
+// SPDX-License-Identifier: Apache-2.0
+
+package is
+
+// EqualTo(b)(a) is the same as a == b.
+func EqualTo[T comparable](rhs T) func(T) bool {
+ return func(lhs T) bool {
+ return lhs == rhs
+ }
+}
+
+// DifferentFrom(b)(a) is the same as a != b.
+func DifferentFrom[T comparable](rhs T) func(T) bool {
+ return func(lhs T) bool {
+ return lhs != rhs
+ }
+}