Function
optionalHasValue
(value reflect.Value, info optionalInfo)
Source from the content-addressed store, hash-verified
| 97 | } |
| 98 | |
| 99 | func 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. |
| 118 | type optionalSerializer struct { |
Callers
nothing calls this directly
Tested by
no test coverage detected