Run NodesReferenceutils

maybe

Package maybe

import "github.com/luxfi/node/utils/maybe"

Functions

Equal

func Equal[T any](m1 Maybe[T], m2 Maybe[T], equalFunc func(T, T) bool) bool

Equal returns true if both m1 and m2 are nothing or have the same value according to [equalFunc].

Types

Maybe

Maybe T = Some T | Nothing. A data wrapper that allows values to be something [Some T] or nothing [Nothing]. Invariant: If [hasValue] is false, then [value] is the zero value of type T. Maybe is used to wrap types:

func Bind[T, U any](m Maybe[T], f func(T) U) Maybe[U]
func Nothing[T any]() Maybe[T]
func Some[T any](val T) Maybe[T]
func (m Maybe[T]) HasValue() bool
func (m Maybe[T]) IsNothing() bool
func (m Maybe[T]) String() string
func (m Maybe[T]) Value() T