Skip to content
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

Fix documentation style inconsistencies for IP addresses #85676

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 26 additions & 26 deletions library/std/src/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ impl Ipv4Addr {
Ipv4Addr { inner: c::in_addr { s_addr: u32::from_ne_bytes([a, b, c, d]) } }
}

/// An IPv4 address with the address pointing to localhost: 127.0.0.1.
/// An IPv4 address with the address pointing to localhost: `127.0.0.1`
///
/// # Examples
///
Expand All @@ -332,7 +332,7 @@ impl Ipv4Addr {
#[stable(feature = "ip_constructors", since = "1.30.0")]
pub const LOCALHOST: Self = Ipv4Addr::new(127, 0, 0, 1);

/// An IPv4 address representing an unspecified address: 0.0.0.0
/// An IPv4 address representing an unspecified address: `0.0.0.0`
///
/// This corresponds to the constant `INADDR_ANY` in other languages.
///
Expand All @@ -348,7 +348,7 @@ impl Ipv4Addr {
#[stable(feature = "ip_constructors", since = "1.30.0")]
pub const UNSPECIFIED: Self = Ipv4Addr::new(0, 0, 0, 0);

/// An IPv4 address representing the broadcast address: 255.255.255.255
/// An IPv4 address representing the broadcast address: `255.255.255.255`
///
/// # Examples
///
Expand Down Expand Up @@ -379,7 +379,7 @@ impl Ipv4Addr {
self.inner.s_addr.to_ne_bytes()
}

/// Returns [`true`] for the special 'unspecified' address (0.0.0.0).
/// Returns [`true`] for the special 'unspecified' address (`0.0.0.0`).
///
/// This property is defined in _UNIX Network Programming, Second Edition_,
/// W. Richard Stevens, p. 891; see also [ip7].
Expand All @@ -401,7 +401,7 @@ impl Ipv4Addr {
self.inner.s_addr == 0
}

/// Returns [`true`] if this is a loopback address (127.0.0.0/8).
/// Returns [`true`] if this is a loopback address (`127.0.0.0/8`).
///
/// This property is defined by [IETF RFC 1122].
///
Expand All @@ -426,9 +426,9 @@ impl Ipv4Addr {
///
/// The private address ranges are defined in [IETF RFC 1918] and include:
///
/// - 10.0.0.0/8
/// - 172.16.0.0/12
/// - 192.168.0.0/16
/// - `10.0.0.0/8`
/// - `172.16.0.0/12`
/// - `192.168.0.0/16`
///
/// [IETF RFC 1918]: https://tools.ietf.org/html/rfc1918
///
Expand Down Expand Up @@ -457,7 +457,7 @@ impl Ipv4Addr {
}
}

/// Returns [`true`] if the address is link-local (169.254.0.0/16).
/// Returns [`true`] if the address is link-local (`169.254.0.0/16`).
///
/// This property is defined by [IETF RFC 3927].
///
Expand Down Expand Up @@ -490,7 +490,7 @@ impl Ipv4Addr {
/// - the broadcast address (see [`Ipv4Addr::is_broadcast()`])
/// - addresses used for documentation (see [`Ipv4Addr::is_documentation()`])
/// - the unspecified address (see [`Ipv4Addr::is_unspecified()`]), and the whole
/// 0.0.0.0/8 block
/// `0.0.0.0/8` block
/// - addresses reserved for future protocols (see
/// [`Ipv4Addr::is_ietf_protocol_assignment()`], except
/// `192.0.0.9/32` and `192.0.0.10/32` which are globally routable
Expand Down Expand Up @@ -682,9 +682,9 @@ impl Ipv4Addr {
self.octets()[0] & 240 == 240 && !self.is_broadcast()
}

/// Returns [`true`] if this is a multicast address (224.0.0.0/4).
/// Returns [`true`] if this is a multicast address (`224.0.0.0/4`).
///
/// Multicast addresses have a most significant octet between 224 and 239,
/// Multicast addresses have a most significant octet between `224` and `239`,
/// and is defined by [IETF RFC 5771].
///
/// [IETF RFC 5771]: https://tools.ietf.org/html/rfc5771
Expand All @@ -705,9 +705,9 @@ impl Ipv4Addr {
self.octets()[0] >= 224 && self.octets()[0] <= 239
}

/// Returns [`true`] if this is a broadcast address (255.255.255.255).
/// Returns [`true`] if this is a broadcast address (`255.255.255.255`).
///
/// A broadcast address has all octets set to 255 as defined in [IETF RFC 919].
/// A broadcast address has all octets set to `255` as defined in [IETF RFC 919].
///
/// [IETF RFC 919]: https://tools.ietf.org/html/rfc919
///
Expand All @@ -730,9 +730,9 @@ impl Ipv4Addr {
///
/// This is defined in [IETF RFC 5737]:
///
/// - 192.0.2.0/24 (TEST-NET-1)
/// - 198.51.100.0/24 (TEST-NET-2)
/// - 203.0.113.0/24 (TEST-NET-3)
/// - `192.0.2.0/24` (TEST-NET-1)
/// - `198.51.100.0/24` (TEST-NET-2)
/// - `203.0.113.0/24` (TEST-NET-3)
///
/// [IETF RFC 5737]: https://tools.ietf.org/html/rfc5737
///
Expand Down Expand Up @@ -760,7 +760,7 @@ impl Ipv4Addr {

/// Converts this address to an IPv4-compatible [`IPv6` address].
///
/// a.b.c.d becomes ::a.b.c.d
/// `a.b.c.d` becomes `::a.b.c.d`
///
/// This isn't typically the method you want; these addresses don't typically
/// function on modern systems. Use `to_ipv6_mapped` instead.
Expand All @@ -774,7 +774,7 @@ impl Ipv4Addr {
///
/// assert_eq!(
/// Ipv4Addr::new(192, 0, 2, 255).to_ipv6_compatible(),
/// Ipv6Addr::new(0, 0, 0, 0, 0, 0, 49152, 767)
/// Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0xc000, 0x2ff)
/// );
/// ```
#[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")]
Expand All @@ -789,7 +789,7 @@ impl Ipv4Addr {

/// Converts this address to an IPv4-mapped [`IPv6` address].
///
/// a.b.c.d becomes ::ffff:a.b.c.d
/// `a.b.c.d` becomes `::ffff:a.b.c.d`
///
/// [`IPv6` address]: Ipv6Addr
///
Expand All @@ -799,7 +799,7 @@ impl Ipv4Addr {
/// use std::net::{Ipv4Addr, Ipv6Addr};
///
/// assert_eq!(Ipv4Addr::new(192, 0, 2, 255).to_ipv6_mapped(),
/// Ipv6Addr::new(0, 0, 0, 0, 0, 65535, 49152, 767));
/// Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc000, 0x2ff));
/// ```
#[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1172,7 +1172,7 @@ impl Ipv6Addr {
]
}

/// Returns [`true`] for the special 'unspecified' address (::).
/// Returns [`true`] for the special 'unspecified' address (`::`).
///
/// This property is defined in [IETF RFC 4291].
///
Expand Down Expand Up @@ -1374,7 +1374,7 @@ impl Ipv6Addr {
(self.segments()[0] & 0xffc0) == 0xfe80
}

/// Returns [`true`] if this is a deprecated unicast site-local address (fec0::/10). The
/// Returns [`true`] if this is a deprecated unicast site-local address (`fec0::/10`). The
/// unicast site-local address format is defined in [RFC 4291 section 2.5.7] as:
///
/// ```no_rust
Expand Down Expand Up @@ -1403,7 +1403,7 @@ impl Ipv6Addr {
///
/// # Warning
///
/// As per [RFC 3879], the whole `FEC0::/10` prefix is
/// As per [RFC 3879], the whole `fec0::/10` prefix is
/// deprecated. New software must not support site-local
/// addresses.
///
Expand Down Expand Up @@ -1512,7 +1512,7 @@ impl Ipv6Addr {
}
}

/// Returns [`true`] if this is a multicast address (ff00::/8).
/// Returns [`true`] if this is a multicast address (`ff00::/8`).
///
/// This property is defined by [IETF RFC 4291].
///
Expand Down Expand Up @@ -1568,7 +1568,7 @@ impl Ipv6Addr {
/// Converts this address to an [`IPv4` address]. Returns [`None`] if this address is
/// neither IPv4-compatible or IPv4-mapped.
///
/// ::a.b.c.d and ::ffff:a.b.c.d become a.b.c.d
/// `::a.b.c.d` and `::ffff:a.b.c.d` become `a.b.c.d`
///
/// [`IPv4` address]: Ipv4Addr
///
Expand Down