mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
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>
23 lines
438 B
Go
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
|
|
}
|