Skip to content

Commit

Permalink
fixup! IO Reader: Avoid clearing the scratch buffer before writing
Browse files Browse the repository at this point in the history
This adds the comments requested in pyfisch#80 (comment)
  • Loading branch information
chrysn committed Nov 17, 2018
1 parent 3c8c46e commit b8e504b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ where
}

let transfer_result = {
// Prepare for take() (which consumes its reader) by creating a reference adaptor
// that'll only live in this block
let reference = self.reader.by_ref();
// Append the first to_read bytes of the reader to the scratch vector (or up to
// an error or EOF indicated by a shorter read)
let mut taken = reference.take(to_read as u64);
taken.read_to_end(scratch)
};
Expand Down

0 comments on commit b8e504b

Please sign in to comment.