maybe

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 6 Imported by: 0

README

Simple Maybe/Option struct with json, sql and kaeru compatability

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Maybe

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

Contains some or none value based on ok

func None

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

Create a new Maybe without a value

func Some

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

Create a new Maybe containing a value

func (Maybe[T]) Get

func (o Maybe[T]) Get() (T, bool)

Returns the value and ok, if ok is true there is a value

func (Maybe[T]) IsNone

func (o Maybe[T]) IsNone() bool

func (Maybe[T]) IsSome

func (o Maybe[T]) IsSome() bool

func (Maybe[T]) MarshalJSON

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

func (*Maybe[T]) ParseAny

func (o *Maybe[T]) ParseAny(v any) error

Ensures compatability with kaeru

func (*Maybe[T]) Scan

func (o *Maybe[T]) Scan(src any) error

func (*Maybe[T]) SetDefault

func (o *Maybe[T]) SetDefault()

Default value for kaeru parsing

func (*Maybe[T]) UnmarshalJSON

func (o *Maybe[T]) UnmarshalJSON(data []byte) error

func (Maybe[T]) Unwrap

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

Returns the value or panics if it is None

func (Maybe[T]) Value

func (o Maybe[T]) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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