Skip to content

Commit 3a9a8d4

Browse files
committed
Alter Display for Ipv6Addr for IPv4-compatible addresses
1 parent 6330daa commit 3a9a8d4

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

library/core/src/net/ip_addr.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,14 +1770,8 @@ impl fmt::Display for Ipv6Addr {
17701770
f.write_str("::")
17711771
} else if self.is_loopback() {
17721772
f.write_str("::1")
1773-
} else if let Some(ipv4) = self.to_ipv4() {
1774-
match segments[5] {
1775-
// IPv4 Compatible address
1776-
0 => write!(f, "::{}", ipv4),
1777-
// IPv4 Mapped address
1778-
0xffff => write!(f, "::ffff:{}", ipv4),
1779-
_ => unreachable!(),
1780-
}
1773+
} else if let Some(ipv4) = self.to_ipv4_mapped() {
1774+
write!(f, "::ffff:{}", ipv4)
17811775
} else {
17821776
#[derive(Copy, Clone, Default)]
17831777
struct Span {

0 commit comments

Comments
 (0)