maybe

package
v0.0.0-...-460841a Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Just

func Just[T any](maybe Maybe[T]) T

func JustValid

func JustValid[T any](m Maybe[T]) (t T, ok bool)

func MapNone

func MapNone[T any](m Maybe[T], f func() T) T

func ToPtr

func ToPtr[T any](m Maybe[T]) *T

func Valid

func Valid[T any](maybe Maybe[T]) bool

Types

type Maybe

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

func FromPtr

func FromPtr[T any](t *T) Maybe[T]

func Map

func Map[T, E any](m Maybe[T], f func(T) E) Maybe[E]

Map maybe to different type

func NewJust

func NewJust[T any](v T) Maybe[T]

func NewNone

func NewNone[T any]() Maybe[T]

NewNone used for explicit none value

func (Maybe[T]) MarshalJSON

func (m Maybe[T]) MarshalJSON() ([]byte, error)

func (*Maybe[T]) UnmarshalJSON

func (m *Maybe[T]) UnmarshalJSON(bytes []byte) error

Jump to

Keyboard shortcuts

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