result

package
v0.3.5-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do[T any](v Result[T], f func(*T))

Do applies f to the content of the result if the result is ok

Types

type Result

type Result[T any] interface {
	// Value unwraps the result into a tuple
	Value() (*T, error)

	// IsErr returns true if the result represents an error
	IsErr() bool

	// IsOk returns true if the result is not an error
	IsOk() bool
}

A Result holds a value or an error.

func Bind

func Bind[T any, S any](v Result[T], f func(*T) Result[S]) Result[S]

Bind is like the bind operation for the result monad

func Err

func Err[T any](e error) Result[T]

Err creates an error value

func Map

func Map[T any, S any](v Result[T], f func(*T) *S) Result[S]

Map is like the map operation for the result monad

func Ok

func Ok[T any](x *T) Result[T]

Ok creates a result value

Jump to

Keyboard shortcuts

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