refactored result wrapper func names

This commit is contained in:
milarin 2024-04-04 19:13:43 +02:00
parent faf75185ae
commit 4612cb74b2

View File

@ -13,12 +13,12 @@ func ResultOf[T any](value T, err error) Result[T] {
return Result[T]{value: &value, err: nil} return Result[T]{value: &value, err: nil}
} }
func WrapMapFunc[I, O any](f func(I) (O, error)) func(I) Result[O] { func WrapResultOutputFunc[I, O any](f func(I) (O, error)) func(I) Result[O] {
return func(i I) Result[O] { return ResultOf(f(i)) } return func(i I) Result[O] { return ResultOf(f(i)) }
} }
func ResultFunc[I, O any](f func(I) (O, error)) func(Result[I]) Result[O] { func WrapResultFunc[I, O any](f func(I) (O, error)) func(Result[I]) Result[O] {
resFunc := WrapMapFunc(f) resFunc := WrapResultOutputFunc(f)
nilValue := *new(O) nilValue := *new(O)
return func(r Result[I]) Result[O] { return func(r Result[I]) Result[O] {
v, err := r.Get() v, err := r.Get()