Documentation
¶
Index ¶
- func AssignableTo[T Any](v any) bool
- func Compare(x, y any) (bool, error)
- func ConvertibleTo[T Any](v any) bool
- func IsComparable(value ...any) (is bool)
- func IsPointer(v any) bool
- func IsPrimitive(value any) bool
- func Less(a, b any) (bool, error)
- func ToComparable[T Comparable](value any) (T, error)
- func ToHashable[T Hashable](value any) (T, error)
- func ToOrdered[T Ordered](value any) (T, error)
- func ToPrimitive[T Any](value any) (T, error)
- type Any
- type Comparable
- type Hashable
- type Ordered
- type Serializable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignableTo ¶
func Compare ¶
Compare checks if two values are equal.
It takes two parameters, `x` and `y`, which are compared for equality. If the values are not comparable, an error is returned. If the values are comparable, but not equal, the function returns false. If the values are equal, the function returns true.
func ConvertibleTo ¶
func IsComparable ¶
IsComparable checks if all provided values are of comparable types.
It takes a variable number of arguments of any type and returns a boolean indicating if all values are of types that can be compared for equality, such as numeric types, strings, and booleans.
func IsPointer ¶
IsPointer checks if the provided value is a pointer to a primitive type.
It returns true if the value is a pointer to a recognized primitive type, and false otherwise.
func IsPrimitive ¶
func ToComparable ¶
func ToComparable[T Comparable](value any) (T, error)
ToComparable 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 ToHashable ¶
ToHashable casts the provided value to the type T and returns it. T must be a primitive hashable type. If the value is not of type G, an error is returned.
func ToOrdered ¶
ToOrdered 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.
func ToPrimitive ¶
ToPrimitive 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.
Types ¶
type Any ¶
type Any interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string | ~bool | ~complex64 | ~complex128 }
Any covers all primitive types Runes and bytes are int32 and uint8 respectively
type Comparable ¶
type Comparable interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string | ~bool | ~complex64 | ~complex128 }
Comparable covers all comparable primitive types Runes and bytes are int32 and uint8 respectively
type Hashable ¶
type Hashable interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~string }
Hashable covers all primitive types that are suited to be hashed