result

package
v0.0.0-...-21acb39 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Try

func Try[V any, R any](fn func(value V) Result[R]) func(V) Result[R]

Types

type Error

type Error[T any] struct {
	Err error
}

func (Error[T]) Do

func (err Error[T]) Do(func(T) Result[T]) Result[T]

func (Error[T]) Error

func (err Error[T]) Error() string

func (Error[T]) IfError

func (err Error[T]) IfError(fn func(error)) Result[T]

func (Error[T]) IfOK

func (err Error[T]) IfOK(func(T)) Result[T]

func (Error[T]) String

func (err Error[T]) String() string

type OK

type OK[T any] struct {
	Value T
}

func (OK[T]) Do

func (ok OK[T]) Do(fn func(value T) Result[T]) Result[T]

func (OK[T]) IfError

func (ok OK[T]) IfError(func(error)) Result[T]

func (OK[T]) IfOK

func (ok OK[T]) IfOK(fn func(value T)) Result[T]

func (OK[T]) String

func (ok OK[T]) String() string

type Result

type Result[T any] interface {
	Do(func(result T) Result[T]) Result[T]
	IfOK(func(result T)) Result[T]
	IfError(func(err error)) Result[T]
	// contains filtered or unexported methods
}

func IfOK

func IfOK[V any, R any](value Result[V], fn func(V) Result[R]) (result Result[R])

Jump to

Keyboard shortcuts

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