]> git.lizzy.rs Git - rust.git/commitdiff
Stabilize `Ipv6Addr::to_ipv4_mapped`
authorTobias Bucher <tobiasbucher5991@gmail.com>
Tue, 10 May 2022 16:06:48 +0000 (18:06 +0200)
committerTobias Bucher <tobiasbucher5991@gmail.com>
Tue, 10 May 2022 16:06:48 +0000 (18:06 +0200)
CC #27709 (tracking issue for the `ip` feature which contains more
functions)

The function `Ipv6Addr::to_ipv4` is bad because it also returns an IPv4
address for the IPv6 loopback address `::1`. Stabilize
`Ipv6Addr::to_ipv4_mapped` so we can recommend that function instead.

library/std/src/net/ip.rs

index f629a1a0f991e0135537b55b1770172d37e72810..02ab0129e0fbd5125e0a03dbd0e83b2c91ccf98d 100644 (file)
@@ -1646,8 +1646,6 @@ pub const fn is_multicast(&self) -> bool {
     /// # Examples
     ///
     /// ```
-    /// #![feature(ip)]
-    ///
     /// use std::net::{Ipv4Addr, Ipv6Addr};
     ///
     /// assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).to_ipv4_mapped(), None);
@@ -1656,7 +1654,7 @@ pub const fn is_multicast(&self) -> bool {
     /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4_mapped(), None);
     /// ```
     #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
-    #[unstable(feature = "ip", issue = "27709")]
+    #[stable(feature = "ipv6_to_ipv4_mapped", since = "1.62.0")]
     #[must_use = "this returns the result of the operation, \
                   without modifying the original"]
     #[inline]