Skip to content

Commit 599d089

Browse files
committed
impl From<Bytes> and From<Vec<u8>> for BytesMut
`From<Bytes>` implementation is suboptimal: can be optimized for certain representations of `Bytes`.
1 parent 2428c15 commit 599d089

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/bytes_mut.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,19 @@ impl<'a> From<&'a str> for BytesMut {
10541054
}
10551055
}
10561056

1057+
impl From<Vec<u8>> for BytesMut {
1058+
fn from(src: Vec<u8>) -> BytesMut {
1059+
BytesMut::from_vec(src)
1060+
}
1061+
}
1062+
1063+
impl From<Bytes> for BytesMut {
1064+
fn from(src: Bytes) -> BytesMut {
1065+
// TODO: can be optimized for certain `Bytes` representations
1066+
BytesMut::from(src.as_ref())
1067+
}
1068+
}
1069+
10571070
impl From<BytesMut> for Bytes {
10581071
fn from(src: BytesMut) -> Bytes {
10591072
src.freeze()

0 commit comments

Comments
 (0)