mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-14 00:00:13 +02:00
Add Buf::copy_to_bytes(len) (#439)
This method replaces `Buf::to_bytes()`, providing a method that copies a subset of the remaining buffer into a `Bytes` value. As this is strictly more flexible, `to_bytes()` is removed. Fixes: #129, #398
This commit is contained in:
+2
-2
@@ -961,8 +961,8 @@ impl Buf for BytesMut {
|
||||
}
|
||||
}
|
||||
|
||||
fn to_bytes(&mut self) -> crate::Bytes {
|
||||
self.split().freeze()
|
||||
fn copy_to_bytes(&mut self, len: usize) -> crate::Bytes {
|
||||
self.split_to(len).freeze()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user