forked from M-Labs/artiq
1
0
Fork 0

Rust: fix TcpStream::read.

This commit is contained in:
whitequark 2016-09-27 13:19:32 +00:00
parent b8137103c3
commit 89d4621c09
1 changed files with 1 additions and 1 deletions

View File

@ -293,7 +293,7 @@ impl<'a> Read for TcpStream<'a> {
let (pbuf, pos) = self.buffer.take().unwrap(); let (pbuf, pos) = self.buffer.take().unwrap();
let slice = &pbuf.as_slice()[pos..]; let slice = &pbuf.as_slice()[pos..];
let len = ::std::cmp::min(buf.len(), slice.len()); let len = ::std::cmp::min(buf.len(), slice.len());
buf.copy_from_slice(&slice[..len]); buf[..len].copy_from_slice(&slice[..len]);
if len < slice.len() { if len < slice.len() {
self.buffer = Some((pbuf, pos + len)) self.buffer = Some((pbuf, pos + len))
} }