uintptr.go 507 B

123456789101112131415161718192021222324252627282930313233343536
  1. package optional
  2. type Uintptr struct {
  3. isSet bool
  4. value uintptr
  5. }
  6. func NewUintptr(value uintptr) Uintptr {
  7. return Uintptr{
  8. true,
  9. value,
  10. }
  11. }
  12. // EmptyUintptr returns a new Uintptr that does not have a value set.
  13. func EmptyUintptr() Uintptr {
  14. return Uintptr{
  15. false,
  16. 0,
  17. }
  18. }
  19. func (i Uintptr) IsSet() bool {
  20. return i.isSet
  21. }
  22. func (i Uintptr) Value() uintptr {
  23. return i.value
  24. }
  25. func (i Uintptr) Default(defaultValue uintptr) uintptr {
  26. if i.isSet {
  27. return i.value
  28. }
  29. return defaultValue
  30. }