fix(package): [stream] do not call less with a zero value in Max and Min (#422)

* fix(package): [stream] do not call less with a zero value in Max and Min

* test(package): [stream] cover Max and Min with pointer items
This commit is contained in:
Lee Sang Gyu authored and GitHub committed 2026-11-09 12:27:08 +08:00
1 parent 9c56f5f525
commit afc0d3c676
2 files changed
+19 -2

No files matched your search

+2 -2
View File
@@ -373,7 +373,7 @@ func (s Stream[T]) Max(less func(a, b T) bool) (T, bool) {
}
for i, v := range s.source {
if less(v, max) || i == 0 {
if i == 0 || less(v, max) {
max = v
}
}
@@ -391,7 +391,7 @@ func (s Stream[T]) Min(less func(a, b T) bool) (T, bool) {
}
for i, v := range s.source {
if less(v, min) || i == 0 {
if i == 0 || less(v, min) {
min = v
}
}