mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
Rollup merge of #85676 - CDirkx:ip-style, r=JohnTitor
Fix documentation style inconsistencies for IP addresses Pulled out of #85655 as it is unrelated. Fixes some inconsistencies in the docs for IP addresses: - Currently some addresses are backticked, some are not, this PR backticks everything consistently. (looks better imo) - Lowercase hex-literals are used when writing addresses.
This commit is contained in:
commit
e6763c966c
@ -314,7 +314,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
|
||||
///
|
||||
@ -327,7 +327,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.
|
||||
///
|
||||
@ -343,7 +343,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
|
||||
///
|
||||
@ -374,7 +374,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].
|
||||
@ -396,7 +396,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].
|
||||
///
|
||||
@ -421,9 +421,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
|
||||
///
|
||||
@ -452,7 +452,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].
|
||||
///
|
||||
@ -485,7 +485,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
|
||||
@ -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
|
||||
@ -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
|
||||
///
|
||||
@ -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
|
||||
///
|
||||
@ -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.
|
||||
@ -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")]
|
||||
@ -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
|
||||
///
|
||||
@ -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")]
|
||||
@ -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].
|
||||
///
|
||||
@ -1318,7 +1318,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
|
||||
@ -1347,7 +1347,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.
|
||||
///
|
||||
@ -1460,7 +1460,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].
|
||||
///
|
||||
@ -1517,7 +1517,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
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user