Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jhbforlife committed Jan 9, 2024
1 parent 8f5e2ee commit 06b8cf7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions defaults/defaults_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewMyStruct(port int, host string, timeout time.Duration) *MyStruct {
return &s
}

func ExampleSetDefault() {
func ExampleSetFirst() {
fmt.Println(NewMyStruct(0, "", 0))
fmt.Println(NewMyStruct(443, "example.com", 1*time.Minute))
// Output:
Expand All @@ -37,7 +37,7 @@ func MakeMyStruct(port int, host string, timeout time.Duration) *MyStruct {
}
}

func ExampleFirst() {
func ExampleGetFirst() {
fmt.Println(MakeMyStruct(0, "", 0))
fmt.Println(MakeMyStruct(443, "example.com", 1*time.Minute))
// Output:
Expand Down
6 changes: 3 additions & 3 deletions is/is.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func Truthy[T comparable](v T) bool {
// Note that the usual Go type system caveats apply around a nil pointer value not being a nil interface value.
//
// In benchmark testing,
// TruthyAny is approximately 25 times slower than Value,
// TruthyAny is approximately 25 times slower than Truthy,
// and 50 times slower than native Go comparisons.
func TruthyAny[T any](v T) bool {
switch m := any(v).(type) {
Expand All @@ -38,8 +38,8 @@ func TruthyMap[K comparable, V any, M ~map[K]V](v M) bool {
return len(v) > 0
}

// Get returns the truthy value of dereferenced pointers of comparable types.
// Values are truthy if they are not equal to the zero value for the type.
// TruthyPointer returns the truthy value of dereferenced pointers of comparable types.
// Values are truthy if they are not equal to the zero value for the dereferenced type.
// Note that it will evaluate to true for double pointers.
func TruthyPointer[T comparable](v *T) bool {
if v == nil {
Expand Down
12 changes: 6 additions & 6 deletions is/is_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/carlmjohnson/truthy/is"
)

func BenchmarkValueAny_error(b *testing.B) {
func BenchmarkTruthyAny_error(b *testing.B) {
fillVal := errors.New("something")
fill := false
for i := 0; i < b.N; i++ {
Expand All @@ -22,7 +22,7 @@ func BenchmarkValueAny_error(b *testing.B) {
}
}

func BenchmarkValue_error(b *testing.B) {
func BenchmarkTruthy_error(b *testing.B) {
fillVal := errors.New("something")
fill := false
for i := 0; i < b.N; i++ {
Expand Down Expand Up @@ -52,7 +52,7 @@ func Benchmark_error(b *testing.B) {
}
}

func BenchmarkValueAny_string(b *testing.B) {
func BenchmarkTruthyAny_string(b *testing.B) {
fillVal := "something"
fill := false
for i := 0; i < b.N; i++ {
Expand All @@ -67,7 +67,7 @@ func BenchmarkValueAny_string(b *testing.B) {
}
}

func BenchmarkValue_string(b *testing.B) {
func BenchmarkTruthy_string(b *testing.B) {
fillVal := "something"
fill := false
for i := 0; i < b.N; i++ {
Expand Down Expand Up @@ -97,7 +97,7 @@ func Benchmark_string(b *testing.B) {
}
}

func BenchmarkValueAny_int(b *testing.B) {
func BenchmarkTruthyAny_int(b *testing.B) {
fillVal := 1
fill := false
for i := 0; i < b.N; i++ {
Expand All @@ -112,7 +112,7 @@ func BenchmarkValueAny_int(b *testing.B) {
}
}

func BenchmarkValue_int(b *testing.B) {
func BenchmarkTruthy_int(b *testing.B) {
fillVal := 1
fill := false
for i := 0; i < b.N; i++ {
Expand Down
2 changes: 1 addition & 1 deletion is/is_for_any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func test[T any](t *testing.T, v T, ok bool) {
})
}

func TestValueForAny(t *testing.T) {
func TestTruthyAny(t *testing.T) {
var err error
test(t, err, false)
err = (*errT)(nil)
Expand Down
2 changes: 1 addition & 1 deletion ternary/ternary_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func ExampleEvaluate_lazy() {
i := 1
// Cond cannot lazily evaluate its arguments,
// Evaluate cannot lazily evaluate its arguments,
// but you can use a closure to fake it.
s := ternary.Evaluate(
is.Truthy(i),
Expand Down

0 comments on commit 06b8cf7

Please sign in to comment.