Skip to content

Commit 2b0c0f7

Browse files
committed
Auto merge of rust-lang#116506 - Wilfred:remove_tmp_var, r=workingjubilee
Remove unnecessary tmp variable in default_read_exact This `tmp` variable has existed since the original implementation (added in ff81920), but it's not necessary (maybe non-lexical lifetimes helped?). It's common to read std source code to understand how things actually work, and this tripped me up on my first read.
2 parents 11af29e + 6114ce6 commit 2b0c0f7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Diff for: std/src/io/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,7 @@ pub(crate) fn default_read_exact<R: Read + ?Sized>(this: &mut R, mut buf: &mut [
513513
match this.read(buf) {
514514
Ok(0) => break,
515515
Ok(n) => {
516-
let tmp = buf;
517-
buf = &mut tmp[n..];
516+
buf = &mut buf[n..];
518517
}
519518
Err(ref e) if e.is_interrupted() => {}
520519
Err(e) => return Err(e),

0 commit comments

Comments
 (0)