diff options
Diffstat (limited to 'src/buf/buf_mut.rs')
-rw-r--r-- | src/buf/buf_mut.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/buf/buf_mut.rs b/src/buf/buf_mut.rs index f5ed2a7..ab9ad18 100644 --- a/src/buf/buf_mut.rs +++ b/src/buf/buf_mut.rs @@ -990,11 +990,13 @@ impl BufMut for Vec<u8> { unsafe fn advance_mut(&mut self, cnt: usize) { let len = self.len(); let remaining = self.capacity() - len; - if cnt > remaining { - // Reserve additional capacity, and ensure that the total length - // will not overflow usize. - self.reserve(cnt); - } + + assert!( + cnt <= remaining, + "cannot advance past `remaining_mut`: {:?} <= {:?}", + cnt, + remaining + ); self.set_len(len + cnt); } |