MCPcopy Create free account
hub / github.com/cel-expr/cel-go / Subset

Method Subset

common/decls/decls.go:228–254  ·  view source on GitHub ↗

Subset returns a new function declaration which contains only the overloads with the specified IDs. If the subset function contains no overloads, then nil is returned to indicate the function is not functional.

(selector OverloadSelector)

Source from the content-addressed store, hash-verified

226// If the subset function contains no overloads, then nil is returned to indicate the function is not
227// functional.
228func (f *FunctionDecl) Subset(selector OverloadSelector) *FunctionDecl {
229 if f == nil {
230 return nil
231 }
232 overloads := make(map[string]*OverloadDecl)
233 overloadOrdinals := make([]string, 0, len(f.overloadOrdinals))
234 for _, oID := range f.overloadOrdinals {
235 overload := f.overloads[oID]
236 if selector(overload) {
237 overloads[oID] = overload
238 overloadOrdinals = append(overloadOrdinals, oID)
239 }
240 }
241 if len(overloads) == 0 {
242 return nil
243 }
244 subset := &FunctionDecl{
245 name: f.Name(),
246 doc: f.doc,
247 overloads: overloads,
248 singleton: f.singleton,
249 disableTypeGuards: f.disableTypeGuards,
250 state: f.state,
251 overloadOrdinals: overloadOrdinals,
252 }
253 return subset
254}
255
256// AddOverload ensures that the new overload does not collide with an existing overload signature;
257// however, if the function signatures are identical, the implementation may be rewritten as its

Callers 4

ToConfigMethod · 0.80
SubsetFunctionMethod · 0.80

Calls 1

NameMethod · 0.95

Tested by 2