From 29b3b63b404c6a2cec28ff5eb067efe0b054a37f Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Sun, 18 Oct 2026 19:33:33 +0200 Subject: add option.Option.Map() --- options/options.go | 7 ++----- options/options_test.go | 6 ------ 2 files changed, 2 insertions(+), 11 deletions(-) (limited to 'options') diff --git a/options/options.go b/options/options.go index 429f31a..c96cdf9 100644 --- a/options/options.go +++ b/options/options.go @@ -32,11 +32,8 @@ func IsNoneOrZero[T comparable](o Option[T]) bool { // Map applies the given function to the value contained in o, if there is one. func Map[T, U any](o Option[T], mapping func(T) U) Option[U] { - if t, ok := o.Unpack(); ok { - return Some(mapping(t)) - } else { - return None[U]() - } + // TODO: deprecate + return o.Map(mapping) } // Max returns the largest of its input values, while disregarding None values. diff --git a/options/options_test.go b/options/options_test.go index 89b9e14..acb11e4 100644 --- a/options/options_test.go +++ b/options/options_test.go @@ -4,7 +4,6 @@ package options import ( - "strconv" "testing" "go.xyrillian.de/gg/assert" @@ -22,11 +21,6 @@ func TestIsNoneOrZero(t *testing.T) { assert.Equal(t, IsNoneOrZero(Some(1)), false) } -func TestMap(t *testing.T) { - assert.Equal(t, Map(None[int](), strconv.Itoa), None[string]()) - assert.Equal(t, Map(Some(42), strconv.Itoa), Some("42")) -} - func TestMax(t *testing.T) { assert.Equal(t, Max[int](), None[int]()) assert.Equal(t, Max(None[int]()), None[int]()) -- cgit v1.3.1