mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-28 00:00:17 +02:00
Rename hex_impl! to fmt_impl! and reuse it for fmt::Debug (#743)
This commit is contained in:
+2
-11
@@ -36,14 +36,5 @@ impl Debug for BytesRef<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for Bytes {
|
fmt_impl!(Debug, Bytes);
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
|
fmt_impl!(Debug, BytesMut);
|
||||||
Debug::fmt(&BytesRef(self.as_ref()), f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for BytesMut {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
|
|
||||||
Debug::fmt(&BytesRef(self.as_ref()), f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+4
-14
@@ -21,17 +21,7 @@ impl UpperHex for BytesRef<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! hex_impl {
|
fmt_impl!(LowerHex, Bytes);
|
||||||
($tr:ident, $ty:ty) => {
|
fmt_impl!(LowerHex, BytesMut);
|
||||||
impl $tr for $ty {
|
fmt_impl!(UpperHex, Bytes);
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
|
fmt_impl!(UpperHex, BytesMut);
|
||||||
$tr::fmt(&BytesRef(self.as_ref()), f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
hex_impl!(LowerHex, Bytes);
|
|
||||||
hex_impl!(LowerHex, BytesMut);
|
|
||||||
hex_impl!(UpperHex, Bytes);
|
|
||||||
hex_impl!(UpperHex, BytesMut);
|
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
macro_rules! fmt_impl {
|
||||||
|
($tr:ident, $ty:ty) => {
|
||||||
|
impl $tr for $ty {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
|
||||||
|
$tr::fmt(&BytesRef(self.as_ref()), f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
mod debug;
|
mod debug;
|
||||||
mod hex;
|
mod hex;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user