aboutsummaryrefslogtreecommitdiff
path: root/src/bytes.rs
diff options
context:
space:
mode:
authorGravatar Mikhail Zabaluev <mikhail.zabaluev@gmail.com> 2019-12-02 00:00:42 +0200
committerGravatar Carl Lerche <me@carllerche.com> 2019-12-01 14:00:42 -0800
commitaf606aab9be1dde2aeefc1a21344a79beaba7bbe (patch)
tree3ed0e9a8d76d0628b43ef81f62908bdfa838bf7f /src/bytes.rs
parent98951ba26cccb0d613edf0286976aebf48257af0 (diff)
downloadbytes-af606aab9be1dde2aeefc1a21344a79beaba7bbe.tar.gz
bytes-af606aab9be1dde2aeefc1a21344a79beaba7bbe.tar.zst
bytes-af606aab9be1dde2aeefc1a21344a79beaba7bbe.zip
Fix regression in Bytes::truncate (#333)
When the length to truncate is greater than the buffer's current length, do nothing instead of clearing the contents.
Diffstat (limited to 'src/bytes.rs')
-rw-r--r--src/bytes.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/bytes.rs b/src/bytes.rs
index db716c8..d0c9a14 100644
--- a/src/bytes.rs
+++ b/src/bytes.rs
@@ -373,9 +373,7 @@ impl Bytes {
/// [`split_off`]: #method.split_off
#[inline]
pub fn truncate(&mut self, len: usize) {
- if len >= self.len {
- self.len = 0;
- } else {
+ if len < self.len {
self.len = len;
}
}