Add Bytes<&Bytes> for Bytes impl

This commit is contained in:
Nikolay Kim 2022-12-13 11:06:25 +01:00
parent 0217a2e835
commit 959d821edd
5 changed files with 16 additions and 18 deletions

View file

@ -899,6 +899,12 @@ impl Deref for Bytes {
}
}
impl From<&Bytes> for Bytes {
fn from(src: &Bytes) -> Bytes {
src.clone()
}
}
impl From<BytesMut> for Bytes {
fn from(src: BytesMut) -> Bytes {
src.freeze()
@ -4045,8 +4051,7 @@ mod tests {
use super::*;
const LONG: &[u8] =
b"mary had a little lamb, little lamb, little lamb, little lamb, little lamb, little lamb \
const LONG: &[u8] = b"mary had a little lamb, little lamb, little lamb, little lamb, little lamb, little lamb \
mary had a little lamb, little lamb, little lamb, little lamb, little lamb, little lamb \
mary had a little lamb, little lamb, little lamb, little lamb, little lamb, little lamb";