aboutsummaryrefslogtreecommitdiff
path: root/option/option.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2025-01-11 12:23:31 +0100
committerStefan Majewsky <majewsky@gmx.net>2025-01-11 12:23:31 +0100
commit7eec3798588243c493791a421e6224680870d0e2 (patch)
treee6893f9c883c2e3d4d453ae3d54756b13c32e222 /option/option.go
parent49a7790edc4ec9526a7b846399339068990ce7de (diff)
downloadgo-gg-7eec3798588243c493791a421e6224680870d0e2.tar.gz
add options.IsNoneOrZero
Also, add the tests for IsSomeAnd and IsNoneOr that I forgot.
Diffstat (limited to 'option/option.go')
-rw-r--r--option/option.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/option/option.go b/option/option.go
index 992c7b7..39fc56d 100644
--- a/option/option.go
+++ b/option/option.go
@@ -203,6 +203,8 @@ func (o Option[T]) IsSomeAnd(predicate func(T) bool) bool {
}
// IsNoneOr returns whether the Option is either empty, or contains a value that matches the given predicate.
+//
+// If the predicate compares against the zero value, use options.IsNoneOrZero() instead.
func (o Option[T]) IsNoneOr(predicate func(T) bool) bool {
return !o.isSome || predicate(o.value)
}