We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
try_read()
1 parent 18ea998 commit 983532aCopy full SHA for 983532a
libs/stdio/src/lib.rs
@@ -251,10 +251,14 @@ impl<'a> StdioReadGuard<'a> {
251
let mut locked_ring_buf = self.guard.lock();
252
253
// Keep reading if we have empty space in the output buffer
254
- // and available byte in the ring buffer.
255
- while let (Some(buf_elem), Some(queue_elem)) = (buf_iter.next(), locked_ring_buf.queue.pop_front()) {
256
- *buf_elem = queue_elem;
257
- cnt += 1;
+ // and available byte(s) in the ring buffer.
+ while let Some(buf_entry) = buf_iter.next() {
+ if let Some(queue_elem) = locked_ring_buf.queue.pop_front() {
+ *buf_entry = queue_elem;
258
+ cnt += 1;
259
+ } else {
260
+ break;
261
+ }
262
}
263
264
return Ok(cnt);
0 commit comments