@@ -418,6 +418,8 @@ impl IpAddr {
418
418
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1)).to_canonical().is_loopback(), true);
419
419
/// ```
420
420
#[ inline]
421
+ #[ must_use = "this returns the result of the operation, \
422
+ without modifying the original"]
421
423
#[ rustc_const_unstable( feature = "const_ip" , issue = "76205" ) ]
422
424
#[ unstable( feature = "ip" , issue = "27709" ) ]
423
425
pub const fn to_canonical ( & self ) -> IpAddr {
@@ -882,6 +884,8 @@ impl Ipv4Addr {
882
884
/// ```
883
885
#[ rustc_const_stable( feature = "const_ipv4" , since = "1.50.0" ) ]
884
886
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
887
+ #[ must_use = "this returns the result of the operation, \
888
+ without modifying the original"]
885
889
#[ inline]
886
890
pub const fn to_ipv6_compatible ( & self ) -> Ipv6Addr {
887
891
let [ a, b, c, d] = self . octets ( ) ;
@@ -907,6 +911,8 @@ impl Ipv4Addr {
907
911
/// ```
908
912
#[ rustc_const_stable( feature = "const_ipv4" , since = "1.50.0" ) ]
909
913
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
914
+ #[ must_use = "this returns the result of the operation, \
915
+ without modifying the original"]
910
916
#[ inline]
911
917
pub const fn to_ipv6_mapped ( & self ) -> Ipv6Addr {
912
918
let [ a, b, c, d] = self . octets ( ) ;
@@ -1619,6 +1625,8 @@ impl Ipv6Addr {
1619
1625
/// ```
1620
1626
#[ rustc_const_unstable( feature = "const_ipv6" , issue = "76205" ) ]
1621
1627
#[ unstable( feature = "ip" , issue = "27709" ) ]
1628
+ #[ must_use = "this returns the result of the operation, \
1629
+ without modifying the original"]
1622
1630
#[ inline]
1623
1631
pub const fn to_ipv4_mapped ( & self ) -> Option < Ipv4Addr > {
1624
1632
match self . octets ( ) {
@@ -1656,6 +1664,8 @@ impl Ipv6Addr {
1656
1664
/// ```
1657
1665
#[ rustc_const_stable( feature = "const_ipv6" , since = "1.50.0" ) ]
1658
1666
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1667
+ #[ must_use = "this returns the result of the operation, \
1668
+ without modifying the original"]
1659
1669
#[ inline]
1660
1670
pub const fn to_ipv4 ( & self ) -> Option < Ipv4Addr > {
1661
1671
if let [ 0 , 0 , 0 , 0 , 0 , 0 | 0xffff , ab, cd] = self . segments ( ) {
@@ -1679,9 +1689,11 @@ impl Ipv6Addr {
1679
1689
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).is_loopback(), false);
1680
1690
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).to_canonical().is_loopback(), true);
1681
1691
/// ```
1682
- #[ inline]
1683
1692
#[ rustc_const_unstable( feature = "const_ipv6" , issue = "76205" ) ]
1684
1693
#[ unstable( feature = "ip" , issue = "27709" ) ]
1694
+ #[ must_use = "this returns the result of the operation, \
1695
+ without modifying the original"]
1696
+ #[ inline]
1685
1697
pub const fn to_canonical ( & self ) -> IpAddr {
1686
1698
if let Some ( mapped) = self . to_ipv4_mapped ( ) {
1687
1699
return IpAddr :: V4 ( mapped) ;
0 commit comments