MCPcopy Create free account
hub / github.com/apache/fory / optionalHasValue

Function optionalHasValue

go/fory/optional_serializer.go:99–115  ·  view source on GitHub ↗
(value reflect.Value, info optionalInfo)

Source from the content-addressed store, hash-verified

97}
98
99func optionalHasValue(value reflect.Value, info optionalInfo) bool {
100 if value.Kind() == reflect.Ptr {
101 if value.IsNil() {
102 return false
103 }
104 value = value.Elem()
105 }
106 if value.CanAddr() {
107 hasPtr := (*bool)(unsafe.Add(unsafe.Pointer(value.UnsafeAddr()), info.hasOffset))
108 return *hasPtr
109 }
110 field := value.FieldByName("has")
111 if !field.IsValid() {
112 return false
113 }
114 return field.Bool()
115}
116
117// optionalSerializer handles Optional[T] values by writing null flags and delegating to the element serializer.
118type optionalSerializer struct {

Callers

nothing calls this directly

Calls 3

KindMethod · 0.80
BoolMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected