Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
hsldymq committed Mar 31, 2024
1 parent b0c601b commit ec0e34b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion list.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func (l *List[T]) indexOf(item T, startsFrom int) int {

for idx := startsFrom; idx < len(l.elems); idx++ {
elem := l.elems[idx]
if shallowEqual(elem, item) {
if any(elem) == any(item) {
return idx
}
}
Expand Down
14 changes: 5 additions & 9 deletions utils.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package handy

import (
"reflect"
"reflect"
)

func shallowEqual(v1, v2 any) bool {
return v1 == v2
}

func zVal[T any]() T {
var v T
return v
var v T
return v
}

func isTypeComparable[T any]() bool {
var v T
return reflect.ValueOf(v).Comparable()
var v T
return reflect.ValueOf(v).Comparable()
}

0 comments on commit ec0e34b

Please sign in to comment.