Stabilize Ipv6Addr::to_ipv4_mapped

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.
This commit is contained in:
Tobias Bucher 2022-05-10 18:06:48 +02:00
parent eead58e75b
commit 839d97e27e

View 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]