Skip to content

Commit

Permalink
Reorder Ipv6Addr methods so has_unicast_link_local_scope and `has…
Browse files Browse the repository at this point in the history
…_unicast_global_scope` are together
  • Loading branch information
CDirkx committed Jun 16, 2021
1 parent fda30e4 commit 85931ea
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions library/std/src/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1349,30 +1349,6 @@ impl Ipv6Addr {
(self.segments()[0] & 0xffc0) == 0xfe80
}

/// Returns [`true`] if this is an address reserved for documentation
/// (`2001:db8::/32`).
///
/// This property is defined in [IETF RFC 3849].
///
/// [IETF RFC 3849]: https://tools.ietf.org/html/rfc3849
///
/// # Examples
///
/// ```
/// #![feature(ip)]
///
/// use std::net::Ipv6Addr;
///
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_documentation(), false);
/// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_documentation(), true);
/// ```
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_documentation(&self) -> bool {
(self.segments()[0] == 0x2001) && (self.segments()[1] == 0xdb8)
}

/// Returns `true` if the address is a unicast address with global scope,
/// as defined in [RFC 4291].
///
Expand Down Expand Up @@ -1443,6 +1419,30 @@ impl Ipv6Addr {
&& !self.has_unicast_link_local_scope()
}

/// Returns [`true`] if this is an address reserved for documentation
/// (`2001:db8::/32`).
///
/// This property is defined in [IETF RFC 3849].
///
/// [IETF RFC 3849]: https://tools.ietf.org/html/rfc3849
///
/// # Examples
///
/// ```
/// #![feature(ip)]
///
/// use std::net::Ipv6Addr;
///
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_documentation(), false);
/// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_documentation(), true);
/// ```
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_documentation(&self) -> bool {
(self.segments()[0] == 0x2001) && (self.segments()[1] == 0xdb8)
}

/// Returns the address's multicast scope if the address is multicast.
///
/// # Examples
Expand Down

0 comments on commit 85931ea

Please sign in to comment.