results

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must[T any](value T, err error) T

Types

type Result

type Result[T any] struct {
	// contains filtered or unexported fields
}

func Catch added in v0.6.0

func Catch[T any](f func() T) (result Result[T])

Catch map the result of f, wrap panic as error

func CatchE added in v0.6.0

func CatchE[T any](f func() (T, error)) (result Result[T])

CatchE is similar to Catch, but also accept error

func Err

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

func From

func From[T any](value T, err error) Result[T]

func Ok

func Ok[T any](value T) Result[T]

func (Result[T]) Err

func (r Result[T]) Err() error

func (Result[T]) Get

func (r Result[T]) Get() T

func (Result[T]) IsErr

func (r Result[T]) IsErr() bool

func (Result[T]) IsOk

func (r Result[T]) IsOk() bool

func (Result[T]) OrElse

func (r Result[T]) OrElse(other T) T

func (Result[T]) OrEmpty

func (r Result[T]) OrEmpty() T

func (Result[T]) OrFrom added in v0.6.0

func (r Result[T]) OrFrom(fn func() T) T

func (Result[T]) Unpack

func (r Result[T]) Unpack() (T, error)

Jump to

Keyboard shortcuts

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