fn: add conversions between Result and Option

This commit is contained in:
Keagan McClelland committed 2024-11-06 16:39:33 -07:00
1 parent a741c54175
commit 5faad77f33
4 files changed
+58

No files matched your search

+8
View File
@@ -1,6 +1,7 @@
package fn
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
@@ -9,3 +10,10 @@ import (
func TestResultUnwrapOrFail(t *testing.T) {
require.Equal(t, Ok(1).UnwrapOrFail(t), 1)
}
func TestOkToSome(t *testing.T) {
require.Equal(t, Ok(1).OkToSome(), Some(1))
require.Equal(
t, Err[uint8](errors.New("err")).OkToSome(), None[uint8](),
)
}