Documentation ¶
Index ¶
- func As[T any](o interface{}) T
- func AsE[T any](o interface{}, err error) (T, error)
- func Cast[S any](o any) (S, error)
- func CastPointer[T any](p any, err error) (T, error)
- func Conditional[T any](cond bool, a, b T) T
- func ConvertSlice[S, T any](in ...S) []T
- func MapKeyArray[K comparable, V any](m map[K]V) []K
- func MapValues[K comparable, V any](m map[K]V) []V
- func Nil[T any]() T
- func Pointer[T any](t T) *T
- func TryCast[T any](p any) (T, bool)
- func Value[T any](t *T) T
- type Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cast ¶
Cast casts one type parameter to another type parameter, which have a sub type relation. This cannot be described by type parameter constraints in Go, because constraints may not be type parameters again.
func CastPointer ¶
CastPointer casts a pointer/error result to an interface/error result. In Go this cannot be done directly, because returning a nil pinter for an interface return type, would result is a typed nil value for the interface, and not nil, if the pointer is nil. Unfortunately, the relation of the pointer (even the fact, that a pointer is expected)to the interface (even the fact, that an interface is expected) cannot be expressed with Go generics.
func Conditional ¶
func ConvertSlice ¶
func ConvertSlice[S, T any](in ...S) []T
ConvertSlice Converts the element typ of a slice. hereby, Type S must be a subtype of type T.
func MapKeyArray ¶
func MapKeyArray[K comparable, V any](m map[K]V) []K
func MapValues ¶
func MapValues[K comparable, V any](m map[K]V) []V
Types ¶
type Set ¶
type Set[K comparable] map[K]struct{}
func KeySet ¶
func KeySet[K comparable, V any](m map[K]V) Set[K]
func MapKeys ¶
func MapKeys[K comparable, V any](m map[K]V) Set[K]
func NewSet ¶
func NewSet[K comparable](keys ...K) Set[K]