tuple

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tuple

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

Tuple Wrapper for structs that encodes/decodes json as a tuple, rather than dict

func Some

func Some[T any](value T) Tuple[T]

Some builds a Tupe when value is present.

func (Tuple[T]) MarshalJSON

func (t Tuple[T]) MarshalJSON() ([]byte, error)

MarshalJSON custom marshaller for tuple wrapped structs

func (*Tuple[T]) UnmarshalJSON

func (t *Tuple[T]) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes Option from json. This works by creating a temp []interface{}, where each item in the slice is a pointer to the fields of the underlying tuple struct. Since it's pre-filled with pointers, unmarshal fills the pointers and checks the types

func (Tuple[T]) Value

func (t Tuple[T]) Value() T

Value returns the underlying struct

Jump to

Keyboard shortcuts

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