Skip to content

Commit

Permalink
Dont prefix 0x when dbg!(ipv6)
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Jan 20, 2021
1 parent 6b66749 commit 116b66a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/std/src/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,10 +1611,10 @@ impl fmt::Display for Ipv6Addr {
#[inline]
fn fmt_subslice(f: &mut fmt::Formatter<'_>, chunk: &[u16]) -> fmt::Result {
if let Some((first, tail)) = chunk.split_first() {
fmt::LowerHex::fmt(first, f)?;
write!(f, "{:x}", first)?;
for segment in tail {
f.write_char(':')?;
fmt::LowerHex::fmt(segment, f)?;
write!(f, "{:x}", segment)?;
}
}
Ok(())
Expand Down
3 changes: 3 additions & 0 deletions library/std/src/net/ip/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ fn ipv6_addr_to_string() {

// two runs of zeros, equal length
assert_eq!("1::4:5:0:0:8", Ipv6Addr::new(1, 0, 0, 4, 5, 0, 0, 8).to_string());

// don't prefix `0x` to each segment in `dbg!`.
assert_eq!("1::4:5:0:0:8", &format!("{:#?}", Ipv6Addr::new(1, 0, 0, 4, 5, 0, 0, 8)));
}

#[test]
Expand Down

0 comments on commit 116b66a

Please sign in to comment.