From f70ad6d822fbbfad15f4a1416178bf666c2ea5a4 Mon Sep 17 00:00:00 2001 From: quininer Date: Thu, 16 Aug 2018 22:35:50 +0800 Subject: [PATCH] fix vecbuf bytes_vec --- src/common.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common.rs b/src/common.rs index 070caeb..f9900ff 100644 --- a/src/common.rs +++ b/src/common.rs @@ -171,7 +171,11 @@ impl<'a, 'b> Buf for VecBuf<'a, 'b> { fn bytes_vec<'c>(&'c self, dst: &mut [&'c IoVec]) -> usize { let len = cmp::min(self.inner.len() - self.pos, dst.len()); - for i in 0..len { + if len > 0 { + dst[0] = self.bytes().into(); + } + + for i in 1..len { dst[i] = self.inner[self.pos + i].into(); }