Skip to content

Commit fda30e4

Browse files
committed
Rename is_unicast_global etc. to has_unicast_global_scope
1 parent e7fc4c8 commit fda30e4

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

library/std/src/net/ip.rs

+18-17
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,8 @@ impl Ipv6Addr {
12401240
match self.multicast_scope() {
12411241
Some(Ipv6MulticastScope::Global) => true,
12421242
None => {
1243-
self.is_unicast_global() && !(self.is_unique_local() || self.is_documentation())
1243+
self.has_unicast_global_scope()
1244+
&& !(self.is_unique_local() || self.is_documentation())
12441245
}
12451246
_ => false,
12461247
}
@@ -1331,20 +1332,20 @@ impl Ipv6Addr {
13311332
/// use std::net::Ipv6Addr;
13321333
///
13331334
/// // The loopback address (`::1`) does not actually have link-local scope.
1334-
/// assert_eq!(Ipv6Addr::LOCALHOST.is_unicast_link_local(), false);
1335+
/// assert_eq!(Ipv6Addr::LOCALHOST.has_unicast_link_local_scope(), false);
13351336
///
13361337
/// // Only addresses in `fe80::/10` have link-local scope.
1337-
/// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_unicast_link_local(), false);
1338-
/// assert_eq!(Ipv6Addr::new(0xfe80, 0, 0, 0, 0, 0, 0, 0).is_unicast_link_local(), true);
1338+
/// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).has_unicast_link_local_scope(), false);
1339+
/// assert_eq!(Ipv6Addr::new(0xfe80, 0, 0, 0, 0, 0, 0, 0).has_unicast_link_local_scope(), true);
13391340
///
13401341
/// // Addresses outside the stricter `fe80::/64` also have link-local scope.
1341-
/// assert_eq!(Ipv6Addr::new(0xfe80, 0, 0, 1, 0, 0, 0, 0).is_unicast_link_local(), true);
1342-
/// assert_eq!(Ipv6Addr::new(0xfe81, 0, 0, 0, 0, 0, 0, 0).is_unicast_link_local(), true);
1342+
/// assert_eq!(Ipv6Addr::new(0xfe80, 0, 0, 1, 0, 0, 0, 0).has_unicast_link_local_scope(), true);
1343+
/// assert_eq!(Ipv6Addr::new(0xfe81, 0, 0, 0, 0, 0, 0, 0).has_unicast_link_local_scope(), true);
13431344
/// ```
13441345
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
13451346
#[unstable(feature = "ip", issue = "27709")]
13461347
#[inline]
1347-
pub const fn is_unicast_link_local(&self) -> bool {
1348+
pub const fn has_unicast_link_local_scope(&self) -> bool {
13481349
(self.segments()[0] & 0xffc0) == 0xfe80
13491350
}
13501351

@@ -1403,7 +1404,7 @@ impl Ipv6Addr {
14031404
/// [RFC 4291 section 2.5.7]: https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.7
14041405
/// [unspecified address]: Ipv6Addr::is_unspecified
14051406
/// [loopback address]: Ipv6Addr::is_loopback
1406-
/// [link-local address]: Ipv6Addr::is_unicast_link_local
1407+
/// [link-local address]: Ipv6Addr::has_unicast_link_local_scope
14071408
///
14081409
/// # Examples
14091410
///
@@ -1413,33 +1414,33 @@ impl Ipv6Addr {
14131414
/// use std::net::Ipv6Addr;
14141415
///
14151416
/// // The unspecified address (`::`) does not have unicast global scope
1416-
/// assert_eq!(Ipv6Addr::UNSPECIFIED.is_unicast_global(), false);
1417+
/// assert_eq!(Ipv6Addr::UNSPECIFIED.has_unicast_global_scope(), false);
14171418
///
14181419
/// // The loopback address (`::1`) does not have unicast global scope.
1419-
/// assert_eq!(Ipv6Addr::LOCALHOST.is_unicast_global(), false);
1420+
/// assert_eq!(Ipv6Addr::LOCALHOST.has_unicast_global_scope(), false);
14201421
///
14211422
/// // A unicast address with link-local scope (`fe80::/10`) does not have global scope.
1422-
/// assert_eq!(Ipv6Addr::new(0xfe80, 0, 0, 0, 0, 0, 0, 0).is_unicast_global(), false);
1423+
/// assert_eq!(Ipv6Addr::new(0xfe80, 0, 0, 0, 0, 0, 0, 0).has_unicast_global_scope(), false);
14231424
///
14241425
/// // A unicast address that had the deprecated site-local scope (`fec0::/10`) now has global scope.
1425-
/// assert_eq!(Ipv6Addr::new(0xfec2, 0, 0, 0, 0, 0, 0, 0).is_unicast_global(), true);
1426+
/// assert_eq!(Ipv6Addr::new(0xfec2, 0, 0, 0, 0, 0, 0, 0).has_unicast_global_scope(), true);
14261427
///
14271428
/// // Any multicast address (`ff00::/8`) does not have unicast global scope;
14281429
/// // there is a difference between unicast global scope and multicast global scope.
1429-
/// assert_eq!(Ipv6Addr::new(0xff03, 0, 0, 0, 0, 0, 0, 0).is_unicast_global(), false);
1430-
/// assert_eq!(Ipv6Addr::new(0xff0e, 0, 0, 0, 0, 0, 0, 0).is_unicast_global(), false);
1430+
/// assert_eq!(Ipv6Addr::new(0xff03, 0, 0, 0, 0, 0, 0, 0).has_unicast_global_scope(), false);
1431+
/// assert_eq!(Ipv6Addr::new(0xff0e, 0, 0, 0, 0, 0, 0, 0).has_unicast_global_scope(), false);
14311432
///
14321433
/// // Any other address is defined as having unicast global scope.
1433-
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_global(), true);
1434+
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).has_unicast_global_scope(), true);
14341435
/// ```
14351436
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
14361437
#[unstable(feature = "ip", issue = "27709")]
14371438
#[inline]
1438-
pub const fn is_unicast_global(&self) -> bool {
1439+
pub const fn has_unicast_global_scope(&self) -> bool {
14391440
self.is_unicast()
14401441
&& !self.is_unspecified()
14411442
&& !self.is_loopback()
1442-
&& !self.is_unicast_link_local()
1443+
&& !self.has_unicast_link_local_scope()
14431444
}
14441445

14451446
/// Returns the address's multicast scope if the address is multicast.

library/std/src/net/ip/tests.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -518,14 +518,14 @@ fn ipv6_properties() {
518518
assert!(!ip!($s).is_global());
519519
}
520520
if ($mask & unicast_link_local) == unicast_link_local {
521-
assert!(ip!($s).is_unicast_link_local());
521+
assert!(ip!($s).has_unicast_link_local_scope());
522522
} else {
523-
assert!(!ip!($s).is_unicast_link_local());
523+
assert!(!ip!($s).has_unicast_link_local_scope());
524524
}
525525
if ($mask & unicast_global) == unicast_global {
526-
assert!(ip!($s).is_unicast_global());
526+
assert!(ip!($s).has_unicast_global_scope());
527527
} else {
528-
assert!(!ip!($s).is_unicast_global());
528+
assert!(!ip!($s).has_unicast_global_scope());
529529
}
530530
if ($mask & documentation) == documentation {
531531
assert!(ip!($s).is_documentation());
@@ -883,14 +883,14 @@ fn ipv6_const() {
883883
const IS_UNIQUE_LOCAL: bool = IP_ADDRESS.is_unique_local();
884884
assert!(!IS_UNIQUE_LOCAL);
885885

886-
const IS_UNICAST_LINK_LOCAL: bool = IP_ADDRESS.is_unicast_link_local();
887-
assert!(!IS_UNICAST_LINK_LOCAL);
886+
const HAS_UNICAST_LINK_LOCAL_SCOPE: bool = IP_ADDRESS.has_unicast_link_local_scope();
887+
assert!(!HAS_UNICAST_LINK_LOCAL_SCOPE);
888888

889889
const IS_DOCUMENTATION: bool = IP_ADDRESS.is_documentation();
890890
assert!(!IS_DOCUMENTATION);
891891

892-
const IS_UNICAST_GLOBAL: bool = IP_ADDRESS.is_unicast_global();
893-
assert!(!IS_UNICAST_GLOBAL);
892+
const HAS_UNICAST_GLOBAL_SCOPE: bool = IP_ADDRESS.has_unicast_global_scope();
893+
assert!(!HAS_UNICAST_GLOBAL_SCOPE);
894894

895895
const MULTICAST_SCOPE: Option<Ipv6MulticastScope> = IP_ADDRESS.multicast_scope();
896896
assert_eq!(MULTICAST_SCOPE, None);

0 commit comments

Comments
 (0)