We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a9ef798 commit 5cb8303Copy full SHA for 5cb8303
library/std/src/io/mod.rs
@@ -384,14 +384,15 @@ where
384
}
385
386
387
- match r.read(&mut g.buf[g.len..]) {
+ let buf = &mut g.buf[g.len..];
388
+ match r.read(buf) {
389
Ok(0) => return Ok(g.len - start_len),
390
Ok(n) => {
391
// We can't let g.len overflow which would result in the vec shrinking when the function returns. In
392
// particular, that could break read_to_string if the shortened buffer doesn't end on a UTF-8 boundary.
393
// The minimal check would just be a checked_add, but this assert is a bit more precise and should be
394
// just about the same cost.
- assert!(n <= g.buf.len() - g.len);
395
+ assert!(n <= buf.len());
396
g.len += n;
397
398
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
0 commit comments