Add bytes() method to MutByteBuf to allow reading of data already written

without necessitating flipping to ByteBuf.
This commit is contained in:
Paul Cavallaro
2015-07-17 22:22:58 -04:00
parent d20661676f
commit 23ad12f842
2 changed files with 16 additions and 0 deletions
+4
View File
@@ -303,6 +303,10 @@ impl MutByteBuf {
len as usize
}
}
pub fn bytes<'a>(&'a self) -> &'a [u8] {
&self.buf.mem.bytes()[..self.buf.pos()]
}
}
impl MutBuf for MutByteBuf {