RevokeMsg

This commit is contained in:
withchao
2023-05-25 15:40:19 +08:00
parent 30d8276986
commit df148ae5af
4 changed files with 93 additions and 38 deletions
+9
View File
@@ -80,6 +80,15 @@ func DistinctAnyGetComparable[E any, K comparable](es []E, fn func(e E) K) []K {
// Distinct 去重
func Distinct[T comparable](ts []T) []T {
if len(ts) < 2 {
return ts
} else if len(ts) == 2 {
if ts[0] == ts[1] {
return ts[:1]
} else {
return ts
}
}
return DistinctAny(ts, func(t T) T {
return t
})