Skip to content

Commit

Permalink
Auto merge of rust-lang#132116 - matthiaskrgr:rollup-3a0ia4r, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#131790 (Document textual format of SocketAddrV{4,6})
 - rust-lang#131983 (Stabilize shorter-tail-lifetimes)
 - rust-lang#132097 (sanitizer.md: LeakSanitizer is not supported on aarch64 macOS)
 - rust-lang#132107 (Remove visit_expr_post from ast Visitor)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Oct 24, 2024
2 parents 8baae66 + 0ae2951 commit b4ea08d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions core/src/net/socket_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ pub enum SocketAddr {
/// [IETF RFC 793]: https://tools.ietf.org/html/rfc793
/// [`IPv4` address]: Ipv4Addr
///
/// # Textual representation
///
/// `SocketAddrV4` provides a [`FromStr`](crate::str::FromStr) implementation.
/// It accepts an IPv4 address in its [textual representation], followed by a
/// single `:`, followed by the port encoded as a decimal integer. Other
/// formats are not accepted.
///
/// [textual representation]: Ipv4Addr#textual-representation
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -82,6 +91,32 @@ pub struct SocketAddrV4 {
/// [IETF RFC 2553, Section 3.3]: https://tools.ietf.org/html/rfc2553#section-3.3
/// [`IPv6` address]: Ipv6Addr
///
/// # Textual representation
///
/// `SocketAddrV6` provides a [`FromStr`](crate::str::FromStr) implementation,
/// based on the bracketed format recommended by [IETF RFC 5952],
/// with scope identifiers based on those specified in [IETF RFC 4007].
///
/// It accepts addresses consisting of the following elements, in order:
/// - A left square bracket (`[`)
/// - The [textual representation] of an IPv6 address
/// - _Optionally_, a percent sign (`%`) followed by the scope identifier
/// encoded as a decimal integer
/// - A right square bracket (`]`)
/// - A colon (`:`)
/// - The port, encoded as a decimal integer.
///
/// For example, the string `[2001:db8::413]:443` represents a `SocketAddrV6`
/// with the address `2001:db8::413` and port `443`. The string
/// `[2001:db8::413%612]:443` represents the same address and port, with a
/// scope identifier of `612`.
///
/// Other formats are not accepted.
///
/// [IETF RFC 5952]: https://tools.ietf.org/html/rfc5952#section-6
/// [IETF RFC 4007]: https://tools.ietf.org/html/rfc4007#section-11
/// [textual representation]: Ipv6Addr#textual-representation
///
/// # Examples
///
/// ```
Expand All @@ -92,6 +127,10 @@ pub struct SocketAddrV4 {
/// assert_eq!("[2001:db8::1]:8080".parse(), Ok(socket));
/// assert_eq!(socket.ip(), &Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1));
/// assert_eq!(socket.port(), 8080);
///
/// let mut with_scope = socket.clone();
/// with_scope.set_scope_id(3);
/// assert_eq!("[2001:db8::1%3]:8080".parse(), Ok(with_scope));
/// ```
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down

0 comments on commit b4ea08d

Please sign in to comment.