Skip to content

Commit 97201f4

Browse files
committed
fix: fix import conflict
1 parent 89ea2a0 commit 97201f4

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ package e2e_test
1414
import (
1515
"fmt"
1616
. "github.com/initdc/types/option"
17-
types "github.com/initdc/types/result"
17+
. "github.com/initdc/types/result"
1818
"testing"
1919
)
2020

@@ -29,14 +29,14 @@ func TestE2E(t *testing.T) {
2929

3030

3131
// Result
32-
var r1 types.Result[int, string]
32+
var r1 Result[int, string]
3333
r1.Ok(1)
3434

35-
var e1 types.Result[int, string]
35+
var e1 Result[int, string]
3636
e1.Err("error")
3737

38-
r2 := types.Ok[int, string](1)
39-
e2 := types.Err[int, string]("error")
38+
r2 := Ok[int, string](1)
39+
e2 := Err[int, string]("error")
4040

4141
fmt.Printf("%#v\n", s1)
4242
fmt.Printf("%#v\n", s2)

e2e_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package e2e_test
33
import (
44
"fmt"
55
. "github.com/initdc/types/option"
6-
types "github.com/initdc/types/result"
6+
. "github.com/initdc/types/result"
77
"testing"
88
)
99

@@ -18,14 +18,14 @@ func TestE2E(t *testing.T) {
1818

1919

2020
// Result
21-
var r1 types.Result[int, string]
21+
var r1 Result[int, string]
2222
r1.Ok(1)
2323

24-
var e1 types.Result[int, string]
24+
var e1 Result[int, string]
2525
e1.Err("error")
2626

27-
r2 := types.Ok[int, string](1)
28-
e2 := types.Err[int, string]("error")
27+
r2 := Ok[int, string](1)
28+
e2 := Err[int, string]("error")
2929

3030
fmt.Printf("%#v\n", s1)
3131
fmt.Printf("%#v\n", s2)

option/option.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (o Option[T]) UnwrapOrDefault() T {
109109
return zero
110110
}
111111

112-
func Map[T, U any](o Option[T], f func(T) U) Option[U] {
112+
func OptionMap[T, U any](o Option[T], f func(T) U) Option[U] {
113113
if o.some {
114114
return Some[U](f(o.value))
115115
}
@@ -123,21 +123,21 @@ func (o Option[T]) Inspect(f func(T)) Option[T] {
123123
return o
124124
}
125125

126-
func MapOr[T, U any](o Option[T], def U, f func(T) U) U {
126+
func OptionMapOr[T, U any](o Option[T], def U, f func(T) U) U {
127127
if o.some {
128128
return f(o.value)
129129
}
130130
return def
131131
}
132132

133-
func MapOrElse[T, U any](o Option[T], def func() U, f func(T) U) U {
133+
func OptionMapOrElse[T, U any](o Option[T], def func() U, f func(T) U) U {
134134
if o.some {
135135
return f(o.value)
136136
}
137137
return def()
138138
}
139139

140-
func MapOrDefault[T, U any](o Option[T], f func(T) U) U {
140+
func OptionMapOrDefault[T, U any](o Option[T], f func(T) U) U {
141141
if o.some {
142142
return f(o.value)
143143
}
@@ -159,14 +159,14 @@ func OkOrElse[T, E any](o Option[T], err func() E) result.Result[T, E] {
159159
return result.Err[T, E](err())
160160
}
161161

162-
func And[T, U any](o Option[T], optb Option[U]) Option[U] {
162+
func OptionAnd[T, U any](o Option[T], optb Option[U]) Option[U] {
163163
if o.some {
164164
return optb
165165
}
166166
return None[U]()
167167
}
168168

169-
func AndThen[T, U any](o Option[T], f func(T) Option[U]) Option[U] {
169+
func OptionAndThen[T, U any](o Option[T], f func(T) Option[U]) Option[U] {
170170
if o.some {
171171
return f(o.value)
172172
}

option/option_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ func TestUnwrapOrDefault(t *testing.T) {
114114
assert.Equal(t, n.UnwrapOrDefault(), 0)
115115
}
116116

117-
func TestMap(t *testing.T) {
117+
func TestOptionMap(t *testing.T) {
118118
s := Some("Hello, World!")
119-
assert.Equal(t, Map(s, func(s string) int { return len(s) }), Some[int](13))
119+
assert.Equal(t, OptionMap(s, func(s string) int { return len(s) }), Some[int](13))
120120

121121
n := None[string]()
122-
assert.Equal(t, Map(n, func(s string) int { return len(s) }), None[int]())
122+
assert.Equal(t, OptionMap(n, func(s string) int { return len(s) }), None[int]())
123123
}
124124

125125
func TestInspect(t *testing.T) {
@@ -130,31 +130,31 @@ func TestInspect(t *testing.T) {
130130
assert.Equal(t, n.Inspect(func(x int) {}), n)
131131
}
132132

133-
func TestMapOr(t *testing.T) {
133+
func TestOptionMapOr(t *testing.T) {
134134
s := Some("foo")
135-
assert.Equal(t, MapOr(s, 42, func(v string) int { return len(v) }), 3)
135+
assert.Equal(t, OptionMapOr(s, 42, func(v string) int { return len(v) }), 3)
136136

137137
n := None[string]()
138-
assert.Equal(t, MapOr(n, 42, func(v string) int { return len(v) }), 42)
138+
assert.Equal(t, OptionMapOr(n, 42, func(v string) int { return len(v) }), 42)
139139
}
140140

141-
func TestMapOrElse(t *testing.T) {
141+
func TestOptionMapOrElse(t *testing.T) {
142142
k := 21
143143
s := Some("foo")
144-
assert.Equal(t, MapOrElse(s, func() int { return 2 * k }, func(v string) int { return len(v) }), 3)
144+
assert.Equal(t, OptionMapOrElse(s, func() int { return 2 * k }, func(v string) int { return len(v) }), 3)
145145

146146
n := None[string]()
147-
assert.Equal(t, MapOrElse(n, func() int { return 2 * k }, func(v string) int { return len(v) }), 42)
147+
assert.Equal(t, OptionMapOrElse(n, func() int { return 2 * k }, func(v string) int { return len(v) }), 42)
148148
}
149149

150-
func TestMapOrDefault(t *testing.T) {
150+
func TestOptionMapOrDefault(t *testing.T) {
151151
f := func(s string) int { return len(s)}
152152
s := Some("hi")
153153

154-
assert.Equal(t, MapOrDefault(s, f), 2)
154+
assert.Equal(t, OptionMapOrDefault(s, f), 2)
155155

156156
n := None[string]()
157-
assert.Equal(t, MapOrDefault(n, f), 0)
157+
assert.Equal(t, OptionMapOrDefault(n, f), 0)
158158
}
159159

160160
func TestOkOr(t *testing.T) {
@@ -174,35 +174,35 @@ func TestOkOrElse(t *testing.T) {
174174
}
175175

176176

177-
func TestAnd(t *testing.T) {
177+
func TestOptionAnd(t *testing.T) {
178178
x := Some(2)
179179
y := None[string]()
180-
assert.Equal(t, And(x, y), None[string]())
180+
assert.Equal(t, OptionAnd(x, y), None[string]())
181181

182182
x2 := None[int]()
183183
y2 := Some("foo")
184-
assert.Equal(t, And(x2, y2), None[string]())
184+
assert.Equal(t, OptionAnd(x2, y2), None[string]())
185185

186186
x3 := Some(2)
187187
y3 := Some("foo")
188-
assert.Equal(t, And(x3, y3), Some("foo"))
188+
assert.Equal(t, OptionAnd(x3, y3), Some("foo"))
189189

190190
x4 := None[int]()
191191
y4 := None[string]()
192-
assert.Equal(t, And(x4, y4), None[string]())
192+
assert.Equal(t, OptionAnd(x4, y4), None[string]())
193193
}
194194

195-
func TestAndThen(t *testing.T) {
195+
func TestOptionAndThen(t *testing.T) {
196196
sqThenToString := func(x int) Option[string] {
197197
if x > 100 || x < 0 {
198198
return None[string]()
199199
}
200200
return Some(strconv.Itoa(x))
201201
}
202202

203-
assert.Equal(t, AndThen(Some(2), sqThenToString), Some[string]("2"))
204-
assert.Equal(t, AndThen(Some(1000), sqThenToString), None[string]())
205-
assert.Equal(t, AndThen(None[int](), sqThenToString), None[string]())
203+
assert.Equal(t, OptionAndThen(Some(2), sqThenToString), Some[string]("2"))
204+
assert.Equal(t, OptionAndThen(Some(1000), sqThenToString), None[string]())
205+
assert.Equal(t, OptionAndThen(None[int](), sqThenToString), None[string]())
206206
}
207207

208208
func TestFilter(t *testing.T) {

0 commit comments

Comments
 (0)