result

package
v1.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package result provides cross type transformations for `mo.Result`.

The functions provided by this package are not methods of `mo.Result` due to the lack of method type parameters on methods. This is part of the design decision of the Go's generics as explained here: https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#No-parameterized-methods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlatMap

func FlatMap[I any, O any](f func(I) mo.Result[O]) func(result mo.Result[I]) mo.Result[O]

FlatMap returns the result of applying `f` to the value of result, if present, and None otherwise.

func FlatMatch

func FlatMatch[I any, O any](onValue func(I) mo.Result[O], onError func() mo.Result[O]) func(result mo.Result[I]) mo.Result[O]

FlatMatch returns the result of applying `onValue` to the value of result, if present, or the result of `onError` if absent.

func Map

func Map[I any, O any](f func(I) O) func(result mo.Result[I]) mo.Result[O]

Map returns a new `mo.Result` wrapping the result of applying `f` to the value of result, if present, and None otherwise.

func Match

func Match[I any, O any](onValue func(I) (O, error), onError func() (O, error)) func(result mo.Result[I]) mo.Result[O]

Match returns a new `mo.Result` from the result of applying `onValue` to the value of result, if present, or from the result of calling `onError` if absent.

func Pipe1

func Pipe1[A any, B any](
	source mo.Result[A],
	operator1 func(mo.Result[A]) mo.Result[B],
) mo.Result[B]

func Pipe10

func Pipe10[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any, K any](
	source mo.Result[A],
	operator1 func(mo.Result[A]) mo.Result[B],
	operator2 func(mo.Result[B]) mo.Result[C],
	operator3 func(mo.Result[C]) mo.Result[D],
	operator4 func(mo.Result[D]) mo.Result[E],
	operator5 func(mo.Result[E]) mo.Result[F],
	operator6 func(mo.Result[F]) mo.Result[G],
	operator7 func(mo.Result[G]) mo.Result[H],
	operator8 func(mo.Result[H]) mo.Result[I],
	operator9 func(mo.Result[I]) mo.Result[J],
	operator10 func(mo.Result[J]) mo.Result[K],
) mo.Result[K]

func Pipe2

func Pipe2[A any, B any, C any](
	source mo.Result[A],
	operator1 func(mo.Result[A]) mo.Result[B],
	operator2 func(mo.Result[B]) mo.Result[C],
) mo.Result[C]

func Pipe3

func Pipe3[A any, B any, C any, D any](
	source mo.Result[A],
	operator1 func(mo.Result[A]) mo.Result[B],
	operator2 func(mo.Result[B]) mo.Result[C],
	operator3 func(mo.Result[C]) mo.Result[D],
) mo.Result[D]

func Pipe4

func Pipe4[A any, B any, C any, D any, E any](
	source mo.Result[A],
	operator1 func(mo.Result[A]) mo.Result[B],
	operator2 func(mo.Result[B]) mo.Result[C],
	operator3 func(mo.Result[C]) mo.Result[D],
	operator4 func(mo.Result[D]) mo.Result[E],
) mo.Result[E]

func Pipe5

func Pipe5[A any, B any, C any, D any, E any, F any](
	source mo.Result[A],
	operator1 func(mo.Result[A]) mo.Result[B],
	operator2 func(mo.Result[B]) mo.Result[C],
	operator3 func(mo.Result[C]) mo.Result[D],
	operator4 func(mo.Result[D]) mo.Result[E],
	operator5 func(mo.Result[E]) mo.Result[F],
) mo.Result[F]

func Pipe6

func Pipe6[A any, B any, C any, D any, E any, F any, G any](
	source mo.Result[A],
	operator1 func(mo.Result[A]) mo.Result[B],
	operator2 func(mo.Result[B]) mo.Result[C],
	operator3 func(mo.Result[C]) mo.Result[D],
	operator4 func(mo.Result[D]) mo.Result[E],
	operator5 func(mo.Result[E]) mo.Result[F],
	operator6 func(mo.Result[F]) mo.Result[G],
) mo.Result[G]

func Pipe7

func Pipe7[A any, B any, C any, D any, E any, F any, G any, H any](
	source mo.Result[A],
	operator1 func(mo.Result[A]) mo.Result[B],
	operator2 func(mo.Result[B]) mo.Result[C],
	operator3 func(mo.Result[C]) mo.Result[D],
	operator4 func(mo.Result[D]) mo.Result[E],
	operator5 func(mo.Result[E]) mo.Result[F],
	operator6 func(mo.Result[F]) mo.Result[G],
	operator7 func(mo.Result[G]) mo.Result[H],
) mo.Result[H]

func Pipe8

func Pipe8[A any, B any, C any, D any, E any, F any, G any, H any, I any](
	source mo.Result[A],
	operator1 func(mo.Result[A]) mo.Result[B],
	operator2 func(mo.Result[B]) mo.Result[C],
	operator3 func(mo.Result[C]) mo.Result[D],
	operator4 func(mo.Result[D]) mo.Result[E],
	operator5 func(mo.Result[E]) mo.Result[F],
	operator6 func(mo.Result[F]) mo.Result[G],
	operator7 func(mo.Result[G]) mo.Result[H],
	operator8 func(mo.Result[H]) mo.Result[I],
) mo.Result[I]

func Pipe9

func Pipe9[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any](
	source mo.Result[A],
	operator1 func(mo.Result[A]) mo.Result[B],
	operator2 func(mo.Result[B]) mo.Result[C],
	operator3 func(mo.Result[C]) mo.Result[D],
	operator4 func(mo.Result[D]) mo.Result[E],
	operator5 func(mo.Result[E]) mo.Result[F],
	operator6 func(mo.Result[F]) mo.Result[G],
	operator7 func(mo.Result[G]) mo.Result[H],
	operator8 func(mo.Result[H]) mo.Result[I],
	operator9 func(mo.Result[I]) mo.Result[J],
) mo.Result[J]

func TestPipeTypeTransformations

func TestPipeTypeTransformations(t *testing.T)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL