summaryrefslogtreecommitdiff
path: root/internal/util/ptr.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/util/ptr.go')
-rw-r--r--internal/util/ptr.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/util/ptr.go b/internal/util/ptr.go
index 4b7450b66..2ce96e1d1 100644
--- a/internal/util/ptr.go
+++ b/internal/util/ptr.go
@@ -17,6 +17,18 @@
package util
+// EqualPtrs returns whether the values contained within two comparable ptr types are equal.
+func EqualPtrs[T comparable](t1, t2 *T) bool {
+ switch {
+ case t1 == nil:
+ return (t2 == nil)
+ case t2 == nil:
+ return false
+ default:
+ return (*t1 == *t2)
+ }
+}
+
// Ptr returns a pointer to the passed in type
func Ptr[T any](t T) *T {
return &t