aboutsummaryrefslogtreecommitdiff
path: root/options/options.go
diff options
context:
space:
mode:
Diffstat (limited to 'options/options.go')
-rw-r--r--options/options.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/options/options.go b/options/options.go
index e058559..9754e2d 100644
--- a/options/options.go
+++ b/options/options.go
@@ -20,3 +20,11 @@ func FromPointer[T any](value *T) Option[T] {
return Some(*value)
}
}
+
+// IsNoneOrZero returns whether the Option is either empty, or contains a zero value.
+func IsNoneOrZero[T comparable](o Option[T]) bool {
+ return o.IsNoneOr(func(value T) bool {
+ var zero T
+ return zero == value
+ })
+}