Skip to content

Commit

Permalink
Auto merge of #116506 - Wilfred:remove_tmp_var, r=workingjubilee
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Oct 12, 2023
2 parents 9d1e4b7 + dca90f7 commit f562931
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ pub(crate) fn default_read_exact<R: Read + ?Sized>(this: &mut R, mut buf: &mut [
match this.read(buf) {
Ok(0) => break,
Ok(n) => {
let tmp = buf;
buf = &mut tmp[n..];
buf = &mut buf[n..];
}
Err(ref e) if e.is_interrupted() => {}
Err(e) => return Err(e),
Expand Down

0 comments on commit f562931

Please sign in to comment.