aboutsummaryrefslogtreecommitdiff
path: root/option
diff options
context:
space:
mode:
Diffstat (limited to 'option')
-rw-r--r--option/option.go8
-rw-r--r--option/option_test.go2
2 files changed, 8 insertions, 2 deletions
diff --git a/option/option.go b/option/option.go
index a96e87d..8bd614c 100644
--- a/option/option.go
+++ b/option/option.go
@@ -106,7 +106,7 @@
//
// dbURL := GetDatabaseURLFromEnvironment().UnwrapOrPanic("no DB connection found")
// // ^ This is a much clearer phrasing.
-package option
+package option // import "go.xyrillian.de/gg/option"
import (
"database/sql"
@@ -173,6 +173,8 @@ func (o Option[T]) AsSlice() []T {
}
// Filter removes the contained value (if any) from the Option if it does not match the predicate.
+//
+// See package go.xyrillian.de/gg/is for pre-made predicates.
func (o Option[T]) Filter(predicate func(T) bool) Option[T] {
if o.isSome && predicate(o.value) {
return o
@@ -194,6 +196,8 @@ func (o Option[T]) IsSome() bool {
}
// IsSomeAnd returns whether the Option contains a value that matches the given predicate.
+//
+// See package go.xyrillian.de/gg/is for pre-made predicates.
func (o Option[T]) IsSomeAnd(predicate func(T) bool) bool {
return o.isSome && predicate(o.value)
}
@@ -201,6 +205,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.
+//
+// See package go.xyrillian.de/gg/is for pre-made predicates.
func (o Option[T]) IsNoneOr(predicate func(T) bool) bool {
return !o.isSome || predicate(o.value)
}
diff --git a/option/option_test.go b/option/option_test.go
index cc1396f..a5eb3ff 100644
--- a/option/option_test.go
+++ b/option/option_test.go
@@ -9,7 +9,7 @@ import (
"slices"
"testing"
- . "github.com/majewsky/gg/internal/test"
+ . "go.xyrillian.de/gg/internal/test"
)
func TestZeroValue(t *testing.T) {