mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-14 00:00:13 +02:00
added clone to ByteBuf and BytesMut along with simple clone test
This commit is contained in:
@@ -558,3 +558,16 @@ impl<'a, T: ?Sized> PartialEq<&'a T> for Bytes
|
||||
*self == **other
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for BytesMut {
|
||||
fn clone(&self) -> BytesMut {
|
||||
let mut v = Vec::with_capacity(self.len());
|
||||
v.extend_from_slice(&self[..]);
|
||||
BytesMut {
|
||||
mem: Mem { inner : Arc::new(UnsafeCell::new(v.into_boxed_slice())) },
|
||||
pos: self.pos,
|
||||
len: self.len,
|
||||
cap: self.cap,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user