Skip to content

Commit 85931ea

Browse files
committed
Reorder Ipv6Addr methods so has_unicast_link_local_scope and has_unicast_global_scope are together
1 parent fda30e4 commit 85931ea

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

library/std/src/net/ip.rs

+24-24
Original file line numberDiff line numberDiff line change
@@ -1349,30 +1349,6 @@ impl Ipv6Addr {
13491349
(self.segments()[0] & 0xffc0) == 0xfe80
13501350
}
13511351

1352-
/// Returns [`true`] if this is an address reserved for documentation
1353-
/// (`2001:db8::/32`).
1354-
///
1355-
/// This property is defined in [IETF RFC 3849].
1356-
///
1357-
/// [IETF RFC 3849]: https://tools.ietf.org/html/rfc3849
1358-
///
1359-
/// # Examples
1360-
///
1361-
/// ```
1362-
/// #![feature(ip)]
1363-
///
1364-
/// use std::net::Ipv6Addr;
1365-
///
1366-
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_documentation(), false);
1367-
/// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_documentation(), true);
1368-
/// ```
1369-
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1370-
#[unstable(feature = "ip", issue = "27709")]
1371-
#[inline]
1372-
pub const fn is_documentation(&self) -> bool {
1373-
(self.segments()[0] == 0x2001) && (self.segments()[1] == 0xdb8)
1374-
}
1375-
13761352
/// Returns `true` if the address is a unicast address with global scope,
13771353
/// as defined in [RFC 4291].
13781354
///
@@ -1443,6 +1419,30 @@ impl Ipv6Addr {
14431419
&& !self.has_unicast_link_local_scope()
14441420
}
14451421

1422+
/// Returns [`true`] if this is an address reserved for documentation
1423+
/// (`2001:db8::/32`).
1424+
///
1425+
/// This property is defined in [IETF RFC 3849].
1426+
///
1427+
/// [IETF RFC 3849]: https://tools.ietf.org/html/rfc3849
1428+
///
1429+
/// # Examples
1430+
///
1431+
/// ```
1432+
/// #![feature(ip)]
1433+
///
1434+
/// use std::net::Ipv6Addr;
1435+
///
1436+
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_documentation(), false);
1437+
/// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_documentation(), true);
1438+
/// ```
1439+
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1440+
#[unstable(feature = "ip", issue = "27709")]
1441+
#[inline]
1442+
pub const fn is_documentation(&self) -> bool {
1443+
(self.segments()[0] == 0x2001) && (self.segments()[1] == 0xdb8)
1444+
}
1445+
14461446
/// Returns the address's multicast scope if the address is multicast.
14471447
///
14481448
/// # Examples

0 commit comments

Comments
 (0)