Skip to content

Commit 71b9433

Browse files
committed
rename SetOr to SetDefault
1 parent b52007b commit 71b9433

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

container/tree/tree.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ var defaultOptions = &Options{
109109

110110
// Fix ensures all options have valid values, using defaults where necessary.
111111
func (options *Options) Fix() {
112-
op.SetOr(&options.Parent, defaultOptions.Parent)
112+
op.SetDefault(&options.Parent, defaultOptions.Parent)
113113
if options.Branch == "" {
114114
options.Branch = defaultOptions.Branch
115-
op.SetOr(&options.LastBranch, defaultOptions.LastBranch)
115+
op.SetDefault(&options.LastBranch, defaultOptions.LastBranch)
116116
} else if options.LastBranch == "" {
117117
options.LastBranch = options.Branch
118118
}
119-
op.SetOr(&options.Space, defaultOptions.Space)
119+
op.SetDefault(&options.Space, defaultOptions.Space)
120120
}
121121

122122
// Stringify converts a node to a string representation.

op/op.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ func OrFunc[T comparable](a T, b func() T) T {
2424
return a
2525
}
2626

27-
// SetOr sets the value of a to b if a is the zero value for T.
27+
// SetDefault sets the value of a to b if a is the zero value for T.
2828
// It returns the final value of a.
29-
func SetOr[T comparable](a *T, b T) T {
29+
func SetDefault[T comparable](a *T, b T) T {
3030
var zero T
3131
if *a == zero {
3232
*a = b
3333
}
3434
return *a
3535
}
3636

37-
// SetOrFunc sets the value of a to the result of calling b() if a is
37+
// SetDefaultFunc sets the value of a to the result of calling b() if a is
3838
// the zero value for T. It returns the final value of a.
39-
func SetOrFunc[T comparable](a *T, b func() T) T {
39+
func SetDefaultFunc[T comparable](a *T, b func() T) T {
4040
var zero T
4141
if *a == zero {
4242
*a = b()

op/op_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestOrFunc(t *testing.T) {
7070
}
7171
}
7272

73-
func TestSetOr(t *testing.T) {
73+
func TestSetDefault(t *testing.T) {
7474
tests := []struct {
7575
name string
7676
a, b, want int
@@ -82,14 +82,14 @@ func TestSetOr(t *testing.T) {
8282
for _, tt := range tests {
8383
t.Run(tt.name, func(t *testing.T) {
8484
a := tt.a
85-
if got := op.SetOr(&a, tt.b); got != tt.want || a != tt.want {
86-
t.Errorf("SetOr(&%v, %v) = %v, want %v, a = %v, want %v", tt.a, tt.b, got, tt.want, a, tt.want)
85+
if got := op.SetDefault(&a, tt.b); got != tt.want || a != tt.want {
86+
t.Errorf("SetDefault(&%v, %v) = %v, want %v, a = %v, want %v", tt.a, tt.b, got, tt.want, a, tt.want)
8787
}
8888
})
8989
}
9090
}
9191

92-
func TestSetOrFunc(t *testing.T) {
92+
func TestSetDefaultFunc(t *testing.T) {
9393
tests := []struct {
9494
name string
9595
a int
@@ -103,8 +103,8 @@ func TestSetOrFunc(t *testing.T) {
103103
for _, tt := range tests {
104104
t.Run(tt.name, func(t *testing.T) {
105105
a := tt.a
106-
if got := op.SetOrFunc(&a, tt.b); got != tt.want || a != tt.want {
107-
t.Errorf("SetOrFunc(&%v, func()) = %v, want %v, a = %v, want %v", tt.a, got, tt.want, a, tt.want)
106+
if got := op.SetDefaultFunc(&a, tt.b); got != tt.want || a != tt.want {
107+
t.Errorf("SetDefaultFunc(&%v, func()) = %v, want %v, a = %v, want %v", tt.a, got, tt.want, a, tt.want)
108108
}
109109
})
110110
}

0 commit comments

Comments
 (0)