Documentation ¶
Overview ¶
Package ztype adds extra types.
Index ¶
- func Deref[T any](v *T, dv T) T
- func Ptr[T any](t T) *T
- func PtrOrNil[T any](t T) *T
- type Optional
- func (o Optional[V]) Get() (V, bool)
- func (o Optional[V]) MarshalJSON() ([]byte, error)
- func (o *Optional[V]) Scan(v any) error
- func (o *Optional[V]) Set(v V)
- func (o Optional[V]) String() string
- func (o *Optional[V]) UnmarshalJSON(data []byte) error
- func (o *Optional[V]) Unset()
- func (o Optional[V]) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Optional ¶
type Optional[V 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 ¶
NewOptional creates a new Optional for the given value.
func (Optional[V]) Get ¶
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[V]) MarshalJSON ¶
func (*Optional[V]) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.