@@ -426,6 +426,8 @@ impl IpAddr {
426
426
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1)).to_canonical().is_loopback(), true);
427
427
/// ```
428
428
#[ inline]
429
+ #[ must_use = "this returns the result of the operation, \
430
+ without modifying the original"]
429
431
#[ rustc_const_unstable( feature = "const_ip" , issue = "76205" ) ]
430
432
#[ unstable( feature = "ip" , issue = "27709" ) ]
431
433
pub const fn to_canonical ( & self ) -> IpAddr {
@@ -901,6 +903,8 @@ impl Ipv4Addr {
901
903
/// ```
902
904
#[ rustc_const_stable( feature = "const_ipv4" , since = "1.50.0" ) ]
903
905
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
906
+ #[ must_use = "this returns the result of the operation, \
907
+ without modifying the original"]
904
908
#[ inline]
905
909
pub const fn to_ipv6_compatible ( & self ) -> Ipv6Addr {
906
910
let [ a, b, c, d] = self . octets ( ) ;
@@ -926,6 +930,8 @@ impl Ipv4Addr {
926
930
/// ```
927
931
#[ rustc_const_stable( feature = "const_ipv4" , since = "1.50.0" ) ]
928
932
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
933
+ #[ must_use = "this returns the result of the operation, \
934
+ without modifying the original"]
929
935
#[ inline]
930
936
pub const fn to_ipv6_mapped ( & self ) -> Ipv6Addr {
931
937
let [ a, b, c, d] = self . octets ( ) ;
@@ -1648,6 +1654,8 @@ impl Ipv6Addr {
1648
1654
/// ```
1649
1655
#[ rustc_const_unstable( feature = "const_ipv6" , issue = "76205" ) ]
1650
1656
#[ unstable( feature = "ip" , issue = "27709" ) ]
1657
+ #[ must_use = "this returns the result of the operation, \
1658
+ without modifying the original"]
1651
1659
#[ inline]
1652
1660
pub const fn to_ipv4_mapped ( & self ) -> Option < Ipv4Addr > {
1653
1661
match self . octets ( ) {
@@ -1685,6 +1693,8 @@ impl Ipv6Addr {
1685
1693
/// ```
1686
1694
#[ rustc_const_stable( feature = "const_ipv6" , since = "1.50.0" ) ]
1687
1695
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1696
+ #[ must_use = "this returns the result of the operation, \
1697
+ without modifying the original"]
1688
1698
#[ inline]
1689
1699
pub const fn to_ipv4 ( & self ) -> Option < Ipv4Addr > {
1690
1700
if let [ 0 , 0 , 0 , 0 , 0 , 0 | 0xffff , ab, cd] = self . segments ( ) {
@@ -1708,9 +1718,11 @@ impl Ipv6Addr {
1708
1718
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).is_loopback(), false);
1709
1719
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).to_canonical().is_loopback(), true);
1710
1720
/// ```
1711
- #[ inline]
1712
1721
#[ rustc_const_unstable( feature = "const_ipv6" , issue = "76205" ) ]
1713
1722
#[ unstable( feature = "ip" , issue = "27709" ) ]
1723
+ #[ must_use = "this returns the result of the operation, \
1724
+ without modifying the original"]
1725
+ #[ inline]
1714
1726
pub const fn to_canonical ( & self ) -> IpAddr {
1715
1727
if let Some ( mapped) = self . to_ipv4_mapped ( ) {
1716
1728
return IpAddr :: V4 ( mapped) ;
0 commit comments