mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
fix(package): [stream] bound Limit capacity by source length (#400)
This commit is contained in:
1 parent
f525703d9f
commit
70b8fc764e
2 files changed
+16
No files matched your search
@@ -219,6 +219,9 @@ func (s Stream[T]) Limit(maxSize int) Stream[T] {
|
||||
if maxSize < 0 {
|
||||
return FromSlice([]T{})
|
||||
}
|
||||
if maxSize > len(s.source) {
|
||||
maxSize = len(s.source)
|
||||
}
|
||||
|
||||
source := make([]T, 0, maxSize)
|
||||
|
||||
|
||||
Reference in new issue
Block a user