implicitly grow BytesMut; add BufMutExt::chain_mut (#316)

This brings `BytesMut` in line with `Vec<u8>` behavior.

This also fixes an existing bug in BytesMut::bytes_mut that exposes
invalid slices. The bug was recently introduced and was only on master
and never released to `crates.io`.

In order to fix a test, `BufMutExt::chain_mut` is provided. Withou this,
it is not possible to chain two `&mut [u8]`.

Closes #170
This commit is contained in:
Carl Lerche
2019-11-20 12:11:40 -08:00
committed by GitHub
parent 59aea9e871
commit 8135c1f606
6 changed files with 88 additions and 27 deletions
+1 -1
View File
@@ -270,7 +270,7 @@ pub trait BufMut {
fn put_slice(&mut self, src: &[u8]) {
let mut off = 0;
assert!(self.remaining_mut() >= src.len(), "buffer overflow");
assert!(self.remaining_mut() >= src.len(), "buffer overflow; remaining = {}; src = {}", self.remaining_mut(), src.len());
while off < src.len() {
let cnt;