convert

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package convert provides converting helpers

Index

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 AsIs

func AsIs[T any](value T) T

AsIs helper for Map, Flatt

func AsSlice

func AsSlice[T any](value T) []T

AsSlice convert an one element to a slice

func ExtraKeys added in v0.0.10

func ExtraKeys[T, K any](element T, keysExtractor func(T) []K) (out []c.KV[K, T])

ExtraKeys transforms iterable elements to key/value iterator based on applying key, value extractor to the elements

func ExtraVals added in v0.0.10

func ExtraVals[T, V any](element T, valsExtractor func(T) []V) (out []c.KV[T, V])

ExtraVals transforms iterable elements to key/value iterator based on applying key, value extractor to the elements

func KeyValue added in v0.0.10

func KeyValue[T, K, V any](element T, keyExtractor func(T) K, valExtractor func(T) V) c.KV[K, V]

KeyValue transforms one element to one key/value pair

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 NoNilPtrVal added in v0.0.10

func NoNilPtrVal[T any](pointer *T) (t T, ok bool)

NoNilPtrVal returns a value referenced by the pointer or ok==false if the pointer is nil

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 Ptr added in v0.0.10

func Ptr[T any](value T) *T

Ptr converts a value to the value pointer

func PtrVal added in v0.0.10

func PtrVal[T any](pointer *T) (t T)

PtrVal returns a value referenced by the pointer or the zero value if the pointer is nil

func ToSlice

func ToSlice[T any](value T) []T

ToSlice convert an one element to a slice

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL