Check limit bigger than 0 in AsyncShareSequence iterate

This commit is contained in:
Alessio Nossa committed 2025-12-10 18:21:53 +01:00
1 parent a524bda0e2
commit 3c9e1ab0ff
1 file changed
+1 -1
@@ -426,7 +426,7 @@ where Base.Element: Sendable, Base: SendableMetatype, Base.AsyncIterator: Sendab
if let limit {
let cancelled = await withUnsafeContinuation { (continuation: UnsafeContinuation<Bool, Never>) in
let (resume, cancelled) = state.withLock { state -> (UnsafeContinuation<Bool, Never>?, Bool) in
guard state.buffer.count >= limit else {
guard limit > 0, state.buffer.count >= limit else {
assert(state.limit == nil)
guard case .cancelled = state.iteratingTask else {
return (continuation, false)