Documentation
¶
Overview ¶
Package convert provides converting helpers
Index ¶
- func And[I, O, N any](first func(I) O, second func(O) N) func(I) N
- func AsIs[T any](value T) T
- func AsSlice[T any](value T) []T
- func ExtraKeys[T, K any](element T, keysExtractor func(T) []K) (out []c.KV[K, T])
- func ExtraVals[T, V any](element T, valsExtractor func(T) []V) (out []c.KV[T, V])
- func KeyValue[T, K, V any](element T, keyExtractor func(T) K, valExtractor func(T) V) c.KV[K, V]
- func KeysValues[T, K, V any](element T, keysExtractor func(T) []K, valsExtractor func(T) []V) (out []c.KV[K, V])
- func NilSafe[From, To any](converter func(*From) *To) func(f *From) (*To, bool)
- func Or[I, O comparable](first func(I) O, second func(I) O) func(I) O
- func ToPtr[T any](value T) *T
- func ToSlice[T any](value T) []T
- func ToType[T, I any](i I) (T, bool)
- func ToVal[T any](pointer *T) (t T)
- func ToValNotNil[T any](pointer *T) (t T, ok bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func And ¶
func And[I, O, N any](first func(I) O, second func(O) N) func(I) N
And apply two converters in order.
func ExtraKeys ¶ added in v0.0.10
ExtraKeys transforms iterable elements to key/value iterator based on applying key, value extractor to the elements
func ExtraVals ¶ added in v0.0.10
ExtraVals transforms iterable elements to key/value iterator based on applying key, value extractor to the elements
func KeysValues ¶ added in v0.0.10
func KeysValues[T, K, V any](element T, keysExtractor func(T) []K, valsExtractor func(T) []V) (out []c.KV[K, V])
KeysValues transforms one element to multiple key/value pairs slices.
func NilSafe ¶ added in v0.0.17
NilSafe filters not nil elements, converts that ones, filters not nils after converting and returns them
func Or ¶
func Or[I, O comparable](first func(I) O, second func(I) O) func(I) O
Or applies first Converter, applies second Converter if the first returns zero.
func ToPtr ¶ added in v0.0.17
func ToPtr[T any](value T) *T
ToPtr converts a value to the value pointer
func ToType ¶ added in v0.0.13
ToType converts I to T. If successful, returns the converted value and true.
func ToVal ¶ added in v0.0.17
func ToVal[T any](pointer *T) (t T)
ToVal returns a value referenced by the pointer or the zero value if the pointer is nil
func ToValNotNil ¶ added in v0.0.17
ToValNotNil returns a value referenced by the pointer or ok==false if the pointer is nil
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package as provides as.Is alias
|
Package as provides as.Is alias |
|
Package ptr provides value, pointer convert helpers
|
Package ptr provides value, pointer convert helpers |
|
Package val provides pointer to value convert helpers
|
Package val provides pointer to value convert helpers |