gopass/pkg/set/map.go
google-labs-jules[bot] 86720090b6
docs: Add GoDoc to pkg and improve markdown files (#3251)
This change adds GoDoc comments to many of the public symbols in the
`pkg/` directory. It also includes various improvements to the
documentation in `README.md` and other markdown files in the `docs/`
directory.

This is a partial documentation effort, as requested by the user, to
get a pull request submitted quickly.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2025-09-22 19:37:15 +02:00

23 lines
438 B
Go

package set
// Map takes a slice of a given type and creates a boolean map with keys
// of that type.
func Map[K comparable](in []K) map[K]bool {
m := make(map[K]bool, len(in))
for _, i := range in {
m[i] = true
}
return m
}
// Apply applies the given function to every element of the slice.
func Apply[K comparable](in []K, f func(K) K) []K {
out := make([]K, len(in))
for i, v := range in {
out[i] = f(v)
}
return out
}