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

Function optUnwrap

cel/library.go:948–963  ·  view source on GitHub ↗
(value ref.Val)

Source from the content-addressed store, hash-verified

946}
947
948func optUnwrap(value ref.Val) ref.Val {
949 list := value.(traits.Lister)
950 var unwrappedList []ref.Val
951 iter := list.Iterator()
952 for iter.HasNext() == types.True {
953 val := iter.Next()
954 opt, isOpt := val.(*types.Optional)
955 if !isOpt {
956 return types.WrapErr(fmt.Errorf("value %v is not optional", val))
957 }
958 if opt.HasValue() {
959 unwrappedList = append(unwrappedList, opt.GetValue())
960 }
961 }
962 return types.DefaultTypeAdapter.NativeToValue(unwrappedList)
963}
964
965func enableOptionalSyntax() EnvOption {
966 return func(e *Env) (*Env, error) {

Callers

nothing calls this directly

Calls 7

WrapErrFunction · 0.92
HasValueMethod · 0.80
GetValueMethod · 0.80
IteratorMethod · 0.65
HasNextMethod · 0.65
NextMethod · 0.65
NativeToValueMethod · 0.65

Tested by

no test coverage detected