cmd/info: Use 'info' struct
This commit is contained in:
parent
ea714aba86
commit
894c23c137
3 changed files with 53 additions and 10 deletions
|
|
@ -2,9 +2,20 @@ package slicesx
|
|||
|
||||
import (
|
||||
"golang.org/x/exp/constraints"
|
||||
"golang.org/x/exp/maps"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
// ForSorted iterates over the map in an ordered fashion
|
||||
func ForSorted[K constraints.Ordered, V any](mp map[K]V, callback func(k K, v V)) {
|
||||
keys := maps.Keys(mp)
|
||||
slices.Sort(keys)
|
||||
|
||||
for _, key := range keys {
|
||||
callback(key, mp[key])
|
||||
}
|
||||
}
|
||||
|
||||
// Any returns true if test returns true for any of values.
|
||||
func Any[T any](values []T, test func(T) bool) bool {
|
||||
for _, v := range values {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue