mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-16 00:00:15 +02:00
Rename Buf/BufMut, methods to chunk/chunk_mut (#450)
The `bytes()` / `bytes_mut()` name implies the method returns the full set of bytes represented by `Buf`/`BufMut`. To rectify this, the methods are renamed to `chunk()` and `chunk_mut()` to reflect the partial nature of the returned byte slice. `bytes_vectored()` is renamed `chunks_vectored()`. Closes #447
This commit is contained in:
+4
-4
@@ -445,7 +445,7 @@ impl BytesMut {
|
||||
let additional = new_len - len;
|
||||
self.reserve(additional);
|
||||
unsafe {
|
||||
let dst = self.bytes_mut().as_mut_ptr();
|
||||
let dst = self.chunk_mut().as_mut_ptr();
|
||||
ptr::write_bytes(dst, value, additional);
|
||||
self.set_len(new_len);
|
||||
}
|
||||
@@ -944,7 +944,7 @@ impl Buf for BytesMut {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn bytes(&self) -> &[u8] {
|
||||
fn chunk(&self) -> &[u8] {
|
||||
self.as_slice()
|
||||
}
|
||||
|
||||
@@ -985,7 +985,7 @@ unsafe impl BufMut for BytesMut {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn bytes_mut(&mut self) -> &mut UninitSlice {
|
||||
fn chunk_mut(&mut self) -> &mut UninitSlice {
|
||||
if self.capacity() == self.len() {
|
||||
self.reserve(64);
|
||||
}
|
||||
@@ -1000,7 +1000,7 @@ unsafe impl BufMut for BytesMut {
|
||||
Self: Sized,
|
||||
{
|
||||
while src.has_remaining() {
|
||||
let s = src.bytes();
|
||||
let s = src.chunk();
|
||||
let l = s.len();
|
||||
self.extend_from_slice(s);
|
||||
src.advance(l);
|
||||
|
||||
Reference in New Issue
Block a user