resultext

package
v5.12.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

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

Result represents the result of an operation that is successful or not.

func Err

func Err[T, E any](err E) Result[T, E]

Err returns a Result that contains the given error.

func Ok

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

Ok returns a Result that contains the given values.

func (Result[T, E]) Err

func (r Result[T, E]) Err() E

Err returns the error of the result. To be used after calling IsOK()

func (Result[T, E]) IsErr

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

IsErr returns true if the result is not successful and has an error.

func (Result[T, E]) IsOk

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

IsOk returns true if the result is successful with no error.

func (Result[T, E]) Unwrap

func (r Result[T, E]) Unwrap() T

Unwrap returns the values of the result. It panics if there is no result due to not checking for errors.

Jump to

Keyboard shortcuts

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