mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-15 00:00:18 +02:00
Provide two versions of drain_to and split_off
* `drain_to` and `split_off` take &self and return Bytes. * `drain_to_mut` and `split_off_mut` take &mut self and return BytesMut
This commit is contained in:
+2
-2
@@ -75,14 +75,14 @@ impl ByteBuf {
|
||||
|
||||
/// Splits the buffer into two at the current read index.
|
||||
pub fn drain_read(&mut self) -> BytesMut {
|
||||
let drained = self.mem.drain_to(self.rd);
|
||||
let drained = self.mem.drain_to_mut(self.rd);
|
||||
self.rd = 0;
|
||||
drained
|
||||
}
|
||||
|
||||
/// Splits the buffer into two at the given index.
|
||||
pub fn drain_to(&mut self, at: usize) -> BytesMut {
|
||||
let drained = self.mem.drain_to(at);
|
||||
let drained = self.mem.drain_to_mut(at);
|
||||
|
||||
if at >= self.rd {
|
||||
self.rd = 0;
|
||||
|
||||
Reference in New Issue
Block a user