Implement Borrow<[u8]> for ByteBuf types so they can be properly used in hashmaps

This commit is contained in:
Ivan 2024-08-18 11:40:04 +02:00
parent 1414a28aaf
commit 8dc8c1e35d
3 changed files with 20 additions and 17 deletions

View file

@ -131,6 +131,18 @@ impl std::convert::AsRef<[u8]> for ByteBufOwned {
}
}
impl std::borrow::Borrow<[u8]> for ByteBufOwned {
fn borrow(&self) -> &[u8] {
&self.0
}
}
impl<'a> std::borrow::Borrow<[u8]> for ByteBuf<'a> {
fn borrow(&self) -> &[u8] {
self.0
}
}
impl<'a> std::ops::Deref for ByteBuf<'a> {
type Target = [u8];