/
gotemplate_OptionalUint32.go
75 lines (57 loc) · 1.47 KB
/
gotemplate_OptionalUint32.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Code generated by gotemplate. DO NOT EDIT.
package go_optional
import "github.com/camullen/go_optional/generic"
// template type Optional(A)
type OptionalUint32 struct {
value *uint32
}
func NewOptionalUint32(v uint32) OptionalUint32 {
return OptionalUint32{value: &v}
}
func NoneOptionalUint32() OptionalUint32 {
return OptionalUint32{value: nil}
}
func (o OptionalUint32) IsNone() bool {
return o.value == nil
}
func (o OptionalUint32) IsSome() bool {
return !o.IsNone()
}
func (o OptionalUint32) Expect(msg string) uint32 {
if o.IsNone() {
panic(msg)
}
return *o.value
}
func (o OptionalUint32) Unwrap() uint32 {
return o.Expect("Optional unwrapped with nil value")
}
func (o OptionalUint32) UnwrapOr(def *uint32) uint32 {
if o.IsNone() {
return *def
}
return *o.value
}
type MapFuncOptionalUint32 func(value *uint32) *uint32
func (o OptionalUint32) Map(mapperFunc MapFuncOptionalUint32) OptionalUint32 {
if o.IsNone() {
return o
}
newVal := mapperFunc(o.value)
return OptionalUint32{value: newVal}
}
func (o OptionalUint32) MapInto(mapIntoFunc MapIntoFuncOptionalUint32) generic.OptionalGeneric {
if o.IsNone() {
return generic.NoneOptionalGeneric()
}
result := mapIntoFunc(o.value)
return generic.NewOptionalGeneric(result)
}
type MapIntoFuncOptionalUint32 func(value *uint32) *interface{}
func (o OptionalUint32) Set(value uint32) OptionalUint32 {
o.value = &value
return o
}
func (o *OptionalUint32) SetMutate(value uint32) {
o.value = &value
}