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

Method Subset

common/decls/decls.go:229–255  ·  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

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