Skip to content

Commit 14bec09

Browse files
committed
Clean up read_all
1 parent bcd8c52 commit 14bec09

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/util.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ pub fn parse_update_count(tag: String) -> u64 {
66
}
77

88
pub fn read_all<R: Read>(r: &mut R, mut buf: &mut [u8]) -> io::Result<()> {
9-
let mut start = 0;
10-
while start != buf.len() {
11-
match r.read(&mut buf[start..]) {
9+
while !buf.is_empty() {
10+
match r.read(buf) {
1211
Ok(0) => return Err(io::Error::new(io::ErrorKind::Other, "unexpected EOF")),
13-
Ok(len) => start += len,
12+
Ok(len) => buf = &mut {buf}[len..],
1413
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {}
1514
Err(e) => return Err(e),
1615
}

0 commit comments

Comments
 (0)