MCPcopy Create free account
hub / github.com/NV404/gova / UpdateWhere

Function UpdateWhere

state_slice.go:147–161  ·  view source on GitHub ↗

UpdateWhere is the type-safe free-function version.

(s *StateValue[[]T], pred func(T) bool, mut func(T) T)

Source from the content-addressed store, hash-verified

145
146// UpdateWhere is the type-safe free-function version.
147func UpdateWhere[T any](s *StateValue[[]T], pred func(T) bool, mut func(T) T) {
148 s.mu.Lock()
149 for i, el := range s.value {
150 if pred(el) {
151 s.value[i] = mut(el)
152 }
153 }
154 v := s.value
155 s.mu.Unlock()
156
157 s.notifyInternal(v)
158 if s.onStateChange != nil {
159 s.onStateChange()
160 }
161}

Callers

nothing calls this directly

Calls 1

notifyInternalMethod · 0.80

Tested by

no test coverage detected