Skip to content

Commit 20233b9

Browse files
committed
std: IPv6 addresses are represented as eight groups of four HEXADECIMAL digits
1 parent 2cc1e16 commit 20233b9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libstd/io/net/ip.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl ToStr for IpAddr {
4141
}
4242

4343
Ipv6Addr(a, b, c, d, e, f, g, h) =>
44-
format!("{}:{}:{}:{}:{}:{}:{}:{}", a, b, c, d, e, f, g, h)
44+
format!("{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}", a, b, c, d, e, f, g, h)
4545
}
4646
}
4747
}
@@ -449,6 +449,7 @@ mod test {
449449
fn ipv6_addr_to_str() {
450450
let a1 = Ipv6Addr(0, 0, 0, 0, 0, 0xffff, 0xc000, 0x280);
451451
assert!(a1.to_str() == ~"::ffff:192.0.2.128" || a1.to_str() == ~"::FFFF:192.0.2.128");
452+
assert_eq!(Ipv6Addr(8, 9, 10, 11, 12, 13, 14, 15).to_str(), ~"8:9:a:b:c:d:e:f");
452453
}
453454

454455
}

0 commit comments

Comments
 (0)