optional

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntoTime

func IntoTime(o Of[time.Time]) null.Time

Types

type Of

type Of[T any] struct {
	V     T
	Valid bool
}

func From

func From[T any](v T) Of[T]

func FromNonZero added in v0.4.8

func FromNonZero[T comparable](v T) Of[T]

func FromNonZeroSlice added in v0.4.8

func FromNonZeroSlice[T any](s []T) Of[[]T]

func FromTime

func FromTime(t null.Time) Of[time.Time]

func Map added in v0.4.8

func Map[T, U any](o Of[T], mapper func(T) U) Of[U]

func MapErr added in v0.7.0

func MapErr[T, U any](o Of[T], mapper func(T) (U, error)) (Of[U], error)

func MapSlice added in v0.7.4

func MapSlice[T, U any](o Of[[]T], mapper func(T) U) Of[[]U]

func None

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

func (Of[T]) ValueOrZero

func (o Of[T]) ValueOrZero() T

ValueOrZero 値が入っているときはその値を、そうでないときはゼロ値を返します。

Jump to

Keyboard shortcuts

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