fn: add conversions between Result and Option
This commit is contained in:
4 files changed
+58
No files matched your search
@@ -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](),
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user