MCPcopy Index your code
hub / github.com/coder/coder / ListLazy

Function ListLazy

coderd/util/slice/slice.go:16–24  ·  view source on GitHub ↗

ListLazy returns the converter function for a list, but does not eval the input. Helpful for combining the Map and the List functions.

(convert func(F) T)

Source from the content-addressed store, hash-verified

14// ListLazy returns the converter function for a list, but does not eval
15// the input. Helpful for combining the Map and the List functions.
16func ListLazy[F any, T any](convert func(F) T) func(list []F) []T {
17 return func(list []F) []T {
18 into := make([]T, 0, len(list))
19 for _, item := range list {
20 into = append(into, convert(item))
21 }
22 return into
23 }
24}
25
26// ToStrings works for any type where the base type is a string.
27func ToStrings[T ~string](a []T) []string {

Callers 1

ListFunction · 0.85

Calls 1

convertFunction · 0.85

Tested by

no test coverage detected