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