diff --git a/ch05/c-fibers/src/main.rs b/ch05/c-fibers/src/main.rs index fccc459..8890a34 100644 --- a/ch05/c-fibers/src/main.rs +++ b/ch05/c-fibers/src/main.rs @@ -95,7 +95,7 @@ impl Runtime { let mut pos = self.current; while self.threads[pos].state != State::Ready { pos += 1; - if pos == self.threads.len() { + if (pos + 1) == self.threads.len() { pos = 0; } if pos == self.current {