results

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 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 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 Try added in v0.6.2

func Try(f func()) (result Result[struct{}])

Try call func f, return Ok[struct{}] if no panic, return Err[struct{}] if panic

func Try1 added in v0.6.3

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

Try1 is similar to Try, but accepts func() T

func Try2 added in v0.6.3

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

Try3 is similar to Try, but accepts func() (T, error)

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