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

Function Find

coderd/util/slice/slice.go:102–110  ·  view source on GitHub ↗

Find returns the first element that satisfies the condition.

(haystack []T, cond func(T) bool)

Source from the content-addressed store, hash-verified

100
101// Find returns the first element that satisfies the condition.
102func Find[T any](haystack []T, cond func(T) bool) (T, bool) {
103 for _, hay := range haystack {
104 if cond(hay) {
105 return hay, true
106 }
107 }
108 var empty T
109 return empty, false
110}
111
112// Filter returns all elements that satisfy the condition.
113func Filter[T any](haystack []T, cond func(T) bool) []T {

Callers 8

TestWorkspaceTimingsFunction · 0.92
TestTasksFunction · 0.92
FilterByPresetMethod · 0.92
renderDevcontainerRowFunction · 0.92
setupStarterTemplateFunction · 0.92

Calls

no outgoing calls

Tested by 4

TestWorkspaceTimingsFunction · 0.74
TestTasksFunction · 0.74