ztype

package
v0.0.0-...-78bcf90 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 3 Imported by: 4

Documentation

Overview

Package ztype adds extra types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deref

func Deref[T any](v *T, dv T) T

Deref dereferences the pointer v, returning dv if it's nil.

func Ptr

func Ptr[T any](t T) *T

Ptr gets a pointer to t.

Types

type Optional

type Optional[Value any] struct {
	// contains filtered or unexported fields
}

Optional represents a value that may or may not exist.

The zero value represents a non-existent value.

type Strukt struct {
    Value zstd.Optional[int]
}

s := Struct{
  Value: zstd.NewOptional[]
}
if v, ok := s.Value.Get(); ok {
}

func NewOptional

func NewOptional[Value any](v Value) Optional[Value]

NewOptional creates a new Optional for the given value.

func (Optional[Value]) Get

func (o Optional[Value]) Get() (Value, bool)

Get the value and a flag indicating if it was set.

The returned value is undefined if it's not set; it can be the type zero value, nil, or anything else.

func (Optional[Value]) MarshalJSON

func (o Optional[Value]) MarshalJSON() ([]byte, error)

func (*Optional[Value]) Scan

func (o *Optional[Value]) Scan(v any) error

func (*Optional[Value]) Set

func (o *Optional[Value]) Set(v Value)

Set a value.

func (Optional[Value]) String

func (o Optional[Value]) String() string

func (*Optional[Value]) UnmarshalJSON

func (o *Optional[Value]) UnmarshalJSON(data []byte) error

func (*Optional[Value]) Unset

func (o *Optional[Value]) Unset()

Unset this optional.

func (Optional[Value]) Value

func (o Optional[Value]) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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