UnpackKinds unpacks the reflect value until it no longer matches the given kinds.
(kinds ...reflect.Kind)
| 185 | |
| 186 | // UnpackKinds unpacks the reflect value until it no longer matches the given kinds. |
| 187 | func (v *Value) UnpackKinds(kinds ...reflect.Kind) *Value { |
| 188 | val := v |
| 189 | for val.isDaselValue() { |
| 190 | var err error |
| 191 | val, err = val.daselValue() |
| 192 | if err != nil { |
| 193 | panic(err) |
| 194 | } |
| 195 | } |
| 196 | res := val.value |
| 197 | for { |
| 198 | if !slices.Contains(kinds, res.Kind()) || res.IsNil() { |
| 199 | return NewValue(res) |
| 200 | } |
| 201 | res = res.Elem() |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | type ErrCouldNotUnpackToType struct { |
| 206 | Type reflect.Type |
no test coverage detected