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:
Nathan Baulch
2025-09-25 06:57:40 +10:00
committed by GitHub
parent 5196e100c3
commit 41cbf0fd2b
5 changed files with 19 additions and 6 deletions
+8 -1
View File
@@ -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) {