Skip to content

Commit e6763c9

Browse files
authored
Rollup merge of rust-lang#85676 - CDirkx:ip-style, r=JohnTitor
Fix documentation style inconsistencies for IP addresses Pulled out of rust-lang#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.
2 parents ed597e7 + 7234141 commit e6763c9

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

library/std/src/net/ip.rs

+26-26
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl Ipv4Addr {
314314
Ipv4Addr { inner: c::in_addr { s_addr: u32::from_ne_bytes([a, b, c, d]) } }
315315
}
316316

317-
/// An IPv4 address with the address pointing to localhost: 127.0.0.1.
317+
/// An IPv4 address with the address pointing to localhost: `127.0.0.1`
318318
///
319319
/// # Examples
320320
///
@@ -327,7 +327,7 @@ impl Ipv4Addr {
327327
#[stable(feature = "ip_constructors", since = "1.30.0")]
328328
pub const LOCALHOST: Self = Ipv4Addr::new(127, 0, 0, 1);
329329

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

346-
/// An IPv4 address representing the broadcast address: 255.255.255.255
346+
/// An IPv4 address representing the broadcast address: `255.255.255.255`
347347
///
348348
/// # Examples
349349
///
@@ -374,7 +374,7 @@ impl Ipv4Addr {
374374
self.inner.s_addr.to_ne_bytes()
375375
}
376376

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

399-
/// Returns [`true`] if this is a loopback address (127.0.0.0/8).
399+
/// Returns [`true`] if this is a loopback address (`127.0.0.0/8`).
400400
///
401401
/// This property is defined by [IETF RFC 1122].
402402
///
@@ -421,9 +421,9 @@ impl Ipv4Addr {
421421
///
422422
/// The private address ranges are defined in [IETF RFC 1918] and include:
423423
///
424-
/// - 10.0.0.0/8
425-
/// - 172.16.0.0/12
426-
/// - 192.168.0.0/16
424+
/// - `10.0.0.0/8`
425+
/// - `172.16.0.0/12`
426+
/// - `192.168.0.0/16`
427427
///
428428
/// [IETF RFC 1918]: https://tools.ietf.org/html/rfc1918
429429
///
@@ -452,7 +452,7 @@ impl Ipv4Addr {
452452
}
453453
}
454454

455-
/// Returns [`true`] if the address is link-local (169.254.0.0/16).
455+
/// Returns [`true`] if the address is link-local (`169.254.0.0/16`).
456456
///
457457
/// This property is defined by [IETF RFC 3927].
458458
///
@@ -485,7 +485,7 @@ impl Ipv4Addr {
485485
/// - the broadcast address (see [`Ipv4Addr::is_broadcast()`])
486486
/// - addresses used for documentation (see [`Ipv4Addr::is_documentation()`])
487487
/// - the unspecified address (see [`Ipv4Addr::is_unspecified()`]), and the whole
488-
/// 0.0.0.0/8 block
488+
/// `0.0.0.0/8` block
489489
/// - addresses reserved for future protocols (see
490490
/// [`Ipv4Addr::is_ietf_protocol_assignment()`], except
491491
/// `192.0.0.9/32` and `192.0.0.10/32` which are globally routable
@@ -682,9 +682,9 @@ impl Ipv4Addr {
682682
self.octets()[0] & 240 == 240 && !self.is_broadcast()
683683
}
684684

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

708-
/// Returns [`true`] if this is a broadcast address (255.255.255.255).
708+
/// Returns [`true`] if this is a broadcast address (`255.255.255.255`).
709709
///
710-
/// A broadcast address has all octets set to 255 as defined in [IETF RFC 919].
710+
/// A broadcast address has all octets set to `255` as defined in [IETF RFC 919].
711711
///
712712
/// [IETF RFC 919]: https://tools.ietf.org/html/rfc919
713713
///
@@ -730,9 +730,9 @@ impl Ipv4Addr {
730730
///
731731
/// This is defined in [IETF RFC 5737]:
732732
///
733-
/// - 192.0.2.0/24 (TEST-NET-1)
734-
/// - 198.51.100.0/24 (TEST-NET-2)
735-
/// - 203.0.113.0/24 (TEST-NET-3)
733+
/// - `192.0.2.0/24` (TEST-NET-1)
734+
/// - `198.51.100.0/24` (TEST-NET-2)
735+
/// - `203.0.113.0/24` (TEST-NET-3)
736736
///
737737
/// [IETF RFC 5737]: https://tools.ietf.org/html/rfc5737
738738
///
@@ -760,7 +760,7 @@ impl Ipv4Addr {
760760

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

790790
/// Converts this address to an IPv4-mapped [`IPv6` address].
791791
///
792-
/// a.b.c.d becomes ::ffff:a.b.c.d
792+
/// `a.b.c.d` becomes `::ffff:a.b.c.d`
793793
///
794794
/// [`IPv6` address]: Ipv6Addr
795795
///
@@ -799,7 +799,7 @@ impl Ipv4Addr {
799799
/// use std::net::{Ipv4Addr, Ipv6Addr};
800800
///
801801
/// assert_eq!(Ipv4Addr::new(192, 0, 2, 255).to_ipv6_mapped(),
802-
/// Ipv6Addr::new(0, 0, 0, 0, 0, 65535, 49152, 767));
802+
/// Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc000, 0x2ff));
803803
/// ```
804804
#[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")]
805805
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1172,7 +1172,7 @@ impl Ipv6Addr {
11721172
]
11731173
}
11741174

1175-
/// Returns [`true`] for the special 'unspecified' address (::).
1175+
/// Returns [`true`] for the special 'unspecified' address (`::`).
11761176
///
11771177
/// This property is defined in [IETF RFC 4291].
11781178
///
@@ -1318,7 +1318,7 @@ impl Ipv6Addr {
13181318
(self.segments()[0] & 0xffc0) == 0xfe80
13191319
}
13201320

1321-
/// Returns [`true`] if this is a deprecated unicast site-local address (fec0::/10). The
1321+
/// Returns [`true`] if this is a deprecated unicast site-local address (`fec0::/10`). The
13221322
/// unicast site-local address format is defined in [RFC 4291 section 2.5.7] as:
13231323
///
13241324
/// ```no_rust
@@ -1347,7 +1347,7 @@ impl Ipv6Addr {
13471347
///
13481348
/// # Warning
13491349
///
1350-
/// As per [RFC 3879], the whole `FEC0::/10` prefix is
1350+
/// As per [RFC 3879], the whole `fec0::/10` prefix is
13511351
/// deprecated. New software must not support site-local
13521352
/// addresses.
13531353
///
@@ -1460,7 +1460,7 @@ impl Ipv6Addr {
14601460
}
14611461
}
14621462

1463-
/// Returns [`true`] if this is a multicast address (ff00::/8).
1463+
/// Returns [`true`] if this is a multicast address (`ff00::/8`).
14641464
///
14651465
/// This property is defined by [IETF RFC 4291].
14661466
///
@@ -1517,7 +1517,7 @@ impl Ipv6Addr {
15171517
/// Converts this address to an [`IPv4` address]. Returns [`None`] if this address is
15181518
/// neither IPv4-compatible or IPv4-mapped.
15191519
///
1520-
/// ::a.b.c.d and ::ffff:a.b.c.d become a.b.c.d
1520+
/// `::a.b.c.d` and `::ffff:a.b.c.d` become `a.b.c.d`
15211521
///
15221522
/// [`IPv4` address]: Ipv4Addr
15231523
///

0 commit comments

Comments
 (0)