Skip to content

doc: improve IpAddr is_glocal and is_unicast_global #25044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions src/libstd/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,13 @@ impl Ipv4Addr {

/// Returns true if the address appears to be globally routable.
///
/// Non-globally-routable networks include the private networks (10.0.0.0/8,
/// 172.16.0.0/12 and 192.168.0.0/16), the loopback network (127.0.0.0/8),
/// the link-local network (169.254.0.0/16), the broadcast address (255.255.255.255/32) and
/// the test networks used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24).
/// The following return false:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this list render correctly without a newline here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will. But thanks for that, because what I needed is add a newline between the bulletted sentences and the sentence leading to them, "The following...".

///
/// - private address (10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16)
/// - the loopback address (127.0.0.0/8)
/// - the link-local address (169.254.0.0/16)
/// - the broadcast address (255.255.255.255/32)
/// - test addresses used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24)
pub fn is_global(&self) -> bool {
!self.is_private() && !self.is_loopback() && !self.is_link_local() &&
!self.is_broadcast() && !self.is_documentation()
Expand Down Expand Up @@ -284,9 +287,11 @@ impl Ipv6Addr {

/// Returns true if the address appears to be globally routable.
///
/// Non-globally-routable networks include the loopback address; the
/// link-local, site-local, and unique local unicast addresses; and the
/// interface-, link-, realm-, admin- and site-local multicast addresses.
/// The following return false:
///
/// - the loopback address
/// - link-local, site-local, and unique local unicast addresses
/// - interface-, link-, realm-, admin- and site-local multicast addresses
pub fn is_global(&self) -> bool {
match self.multicast_scope() {
Some(Ipv6MulticastScope::Global) => true,
Expand Down Expand Up @@ -315,9 +320,12 @@ impl Ipv6Addr {

/// Returns true if the address is a globally routable unicast address.
///
/// Non-globally-routable unicast addresses include the loopback address,
/// the link-local addresses, the deprecated site-local addresses and the
/// unique local addresses.
/// The following return false:
///
/// - the loopback address
/// - the link-local addresses
/// - the (deprecated) site-local addresses
/// - unique local addresses
pub fn is_unicast_global(&self) -> bool {
!self.is_multicast()
&& !self.is_loopback() && !self.is_unicast_link_local()
Expand Down