result

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

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

func Err

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

func Map

func Map[T any, U any](r Result[T], fn func(T) U) Result[U]

This function applies the given function to the Option value and returns the result.

func Ok

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

func Try

func Try[T any, U any](r Result[T], fn func(T) Result[U]) Result[U]

func TryFunc

func TryFunc[T any](fn func() (T, error)) Result[T]

func (Result[T]) AndThen

func (o Result[T]) AndThen(fn func(T) bool) bool

func (*Result[T]) IsErr

func (o *Result[T]) IsErr() bool

Returns true if the Option does not contain a value, false otherwise.

Inverse of IsSome

func (*Result[T]) IsOk

func (o *Result[T]) IsOk() bool

Returns true if the Option contains a value, false otherwise.

Inverse of IsNone

func (Result[T]) Split

func (o Result[T]) Split() (T, error)

func (Result[T]) Then

func (o Result[T]) Then(fn func(T))

func (Result[T]) Unwrap

func (o Result[T]) Unwrap() T

This function returns a copy of the data and not a pointer to it. Panics if the Option is None.

Modifying the result will not modify the original data instead use UnwrapPtr or Map

func (Result[T]) UnwrapErr

func (o Result[T]) UnwrapErr() error

func (Result[T]) UnwrapOr

func (o Result[T]) UnwrapOr(t T) T

func (Result[T]) UnwrapPtr

func (o Result[T]) UnwrapPtr() *T

This function returns a pointer to the data contained in the Option. Panics if the Option is None.

Jump to

Keyboard shortcuts

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