Documentation
¶
Index ¶
- func AssertedTypes[G any](values ...any) []G
- func Bytes(value any) ([]byte, error)
- func NaturalComparable[C comparable](value any) (cmp C, ok bool)
- func Numeric[T nums.Any](value any) (T, error)
- func Primitive[T prim.Any](value any) (T, error)
- func PrimitiveComparable[T prim.Comparable](value any) (T, error)
- func PrimitiveOrdered[T prim.Ordered](value any) (T, error)
- func Type[T any](value any) (cast T, ok bool)
- func Types[G any](values ...any) (result []G, allMatches bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertedTypes ¶
AssertedTypes casts the provided values to the type G and returns a slice of type G. Panics if any value is not of type G.
func Bytes ¶
Bytes casts the provided value to a byte slice and returns it. It returns an error if the value is not of a type that can be cast to a byte slice.
func NaturalComparable ¶
func NaturalComparable[C comparable](value any) (cmp C, ok bool)
NaturalComparable casts the provided values to the type T as value.
Natural comparable types are the types that are comparable by default, such as primitives, strings, booleans, and complex numbers. See the documentation for the comparable type for more information. https://go.dev/blog/comparable
func Numeric ¶
Numeric casts the provided value to the type T and returns it. T must be a numeric type. If the value is not of type T, an error is returned.
func Primitive ¶
Primitive casts the provided value to the type T and returns it. T must be a primitive type. If the value is not of type G, an error is returned.
func PrimitiveComparable ¶
func PrimitiveComparable[T prim.Comparable](value any) (T, error)
PrimitiveComparable casts the provided value to the type T and returns it. T must be a primitive comparable type. If the value is not of type G, an error is returned.
func PrimitiveOrdered ¶
PrimitiveOrdered casts the provided value to the type T and returns it. T must be a primitive ordered type. If the value is not of type G, an error is returned.
Types ¶
This section is empty.