optionalValueSize returns the size of the value being compared, unwrapping nested optional values to the value they contain, and reporting a size of 1 for values which are not sizable.
(value ref.Val)
| 782 | // optionalValueSize returns the size of the value being compared, unwrapping nested optional |
| 783 | // values to the value they contain, and reporting a size of 1 for values which are not sizable. |
| 784 | func optionalValueSize(value ref.Val) uint64 { |
| 785 | for { |
| 786 | opt, isOpt := value.(*types.Optional) |
| 787 | if !isOpt { |
| 788 | break |
| 789 | } |
| 790 | if !opt.HasValue() { |
| 791 | return 1 |
| 792 | } |
| 793 | value = opt.GetValue() |
| 794 | } |
| 795 | if sizer, isSizer := value.(traits.Sizer); isSizer { |
| 796 | if sz, isInt := sizer.Size().(types.Int); isInt { |
| 797 | return uint64(sz) |
| 798 | } |
| 799 | } |
| 800 | return 1 |
| 801 | } |
| 802 | |
| 803 | // Version returns the current version of the library. |
| 804 | func (lib *optionalLib) Version() uint32 { |
no test coverage detected