diff --git a/maps.go b/maps.go index cddd4a4..85dac88 100644 --- a/maps.go +++ b/maps.go @@ -1,6 +1,6 @@ package generics -// MapPairs returns list of map's key-value pairs +// MapPairs returns list of map's key-value pairs. func MapPairs[K comparable, V any](src map[K]V) Pairs[K, V] { dst := make([]Pair[K, V], len(src)) idx := 0 @@ -14,7 +14,7 @@ func MapPairs[K comparable, V any](src map[K]V) Pairs[K, V] { return dst } -// MapKeys returns list of map's keys +// MapKeys returns list of map's keys. func MapKeys[K comparable, V any](src map[K]V) []K { dst := make([]K, len(src)) idx := 0 @@ -25,7 +25,7 @@ func MapKeys[K comparable, V any](src map[K]V) []K { return dst } -// MapValues returns list of map's values +// MapValues returns list of map's values. func MapValues[K comparable, V any](src map[K]V) []V { dst := make([]V, len(src)) idx := 0 @@ -36,7 +36,7 @@ func MapValues[K comparable, V any](src map[K]V) []V { return dst } -// InvertMap returns map with keys and values swapped +// InvertMap returns map with keys and values swapped. func InvertMap[K, V comparable](src map[K]V) map[V]K { if src == nil { return nil diff --git a/ptr.go b/ptr.go index 2e91747..431fdae 100644 --- a/ptr.go +++ b/ptr.go @@ -1,11 +1,11 @@ package generics -// Ptr returns pointer for given value +// Ptr returns pointer for given value. func Ptr[T any](val T) *T { return &val } -// Val returns value of given pointer or default value if pointer is nil +// Val returns value of given pointer or default value if pointer is nil. func Val[T any](ptr *T) T { var val T if ptr != nil { @@ -14,7 +14,7 @@ func Val[T any](ptr *T) T { return val } -// Fallback returns value of given pointer or fallback value if pointer is nil +// Fallback returns value of given pointer or fallback value if pointer is nil. func Fallback[T any](ptr *T, fallback T) T { if ptr != nil { return *ptr