option

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 4 Imported by: 4

README

go-option

A Rust-like error handler for Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Optional

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

func Err

func Err[T any](err_ error) *Optional[T]

func None

func None[T any]() *Optional[T]

func Some

func Some[T any](value T) *Optional[T]

func SomePair

func SomePair[T any](value T, err error) *Optional[T]

func (*Optional[T]) Error

func (o *Optional[T]) Error() string

func (*Optional[T]) Expect

func (o *Optional[T]) Expect(err string) T

func (*Optional[T]) ExpectNil

func (o *Optional[T]) ExpectNil(err string)

func (*Optional[T]) IsNil

func (o *Optional[T]) IsNil() bool

func (*Optional[T]) Or

func (o *Optional[T]) Or(value T) T

func (*Optional[T]) Unwrap

func (o *Optional[T]) Unwrap() T

func (*Optional[T]) UnwrapOrElse

func (o *Optional[T]) UnwrapOrElse(errFn func(err error) T) T

Jump to

Keyboard shortcuts

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