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) boolEqual 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:
- That can't be represented by nil.
- That use nil as a valid value instead of an indicator of a missing value. For more info see https://en.wikipedia.org/wiki/Option_type
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() boolfunc (m Maybe[T]) IsNothing() boolfunc (m Maybe[T]) String() stringfunc (m Maybe[T]) Value() T