mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
feat: preserve type alias in DropByIndex and WithoutBy (#675)
* lint: pin golangci-lint version * feat: preserve type alias in WithoutBy * feat: preserve type alias in DropByIndex --------- Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
This commit is contained in:
+8
-1
@@ -288,8 +288,15 @@ func TestWithoutBy(t *testing.T) {
|
||||
result2 := WithoutBy([]User{}, func(item User) int { return item.Age }, 1, 2, 3)
|
||||
result3 := WithoutBy([]User{}, func(item User) string { return item.Name })
|
||||
is.Equal([]User{{Name: "peter"}}, result1)
|
||||
is.Empty(result2)
|
||||
is.Empty(result2)
|
||||
is.Empty(result3)
|
||||
|
||||
type myStrings []string
|
||||
allStrings := myStrings{"", "foo", "bar"}
|
||||
nonempty := WithoutBy(allStrings, func(s string) string {
|
||||
return s
|
||||
})
|
||||
is.IsType(nonempty, allStrings, "type preserved")
|
||||
}
|
||||
|
||||
func TestWithoutEmpty(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user