mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-11 00:00:23 +02:00
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.
This commit is contained in:
committed by
Carl Lerche
parent
98951ba26c
commit
af606aab9b
+1
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user