Skip to content

Commit

Permalink
deprecate Ipv4Addr::to_ipv6_compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
nanpuyue committed Aug 4, 2020
1 parent cfdf9d3 commit cdf0542
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion library/std/src/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,10 @@ impl Ipv4Addr {
/// );
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(
since = "1.47.0",
reason = "the current IPv6 transition mechanisms no longer use these addresses"
)]
pub fn to_ipv6_compatible(&self) -> Ipv6Addr {
let octets = self.octets();
Ipv6Addr::from([
Expand Down Expand Up @@ -2073,11 +2077,16 @@ mod tests {
}

#[test]
fn ipv4_to_ipv6() {
fn ipv4_to_ipv6_mapped() {
assert_eq!(
Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x1234, 0x5678),
Ipv4Addr::new(0x12, 0x34, 0x56, 0x78).to_ipv6_mapped()
);
}

#[test]
#[allow(deprecated)]
fn ipv4_to_ipv6_compatible() {
assert_eq!(
Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0x1234, 0x5678),
Ipv4Addr::new(0x12, 0x34, 0x56, 0x78).to_ipv6_compatible()
Expand Down

0 comments on commit cdf0542

Please sign in to comment.