Skip to content

Commit 116b66a

Browse files
committed
Dont prefix 0x when dbg!(ipv6)
1 parent 6b66749 commit 116b66a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

library/std/src/net/ip.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1611,10 +1611,10 @@ impl fmt::Display for Ipv6Addr {
16111611
#[inline]
16121612
fn fmt_subslice(f: &mut fmt::Formatter<'_>, chunk: &[u16]) -> fmt::Result {
16131613
if let Some((first, tail)) = chunk.split_first() {
1614-
fmt::LowerHex::fmt(first, f)?;
1614+
write!(f, "{:x}", first)?;
16151615
for segment in tail {
16161616
f.write_char(':')?;
1617-
fmt::LowerHex::fmt(segment, f)?;
1617+
write!(f, "{:x}", segment)?;
16181618
}
16191619
}
16201620
Ok(())

library/std/src/net/ip/tests.rs

+3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ fn ipv6_addr_to_string() {
166166

167167
// two runs of zeros, equal length
168168
assert_eq!("1::4:5:0:0:8", Ipv6Addr::new(1, 0, 0, 4, 5, 0, 0, 8).to_string());
169+
170+
// don't prefix `0x` to each segment in `dbg!`.
171+
assert_eq!("1::4:5:0:0:8", &format!("{:#?}", Ipv6Addr::new(1, 0, 0, 4, 5, 0, 0, 8)));
169172
}
170173

171174
#[test]

0 commit comments

Comments
 (0)