]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Rollup merge of #82487 - CDirkx:const-socketaddr, r=m-ou-se
authorYuki Okushi <jtitor@2k36.org>
Sat, 3 Apr 2021 15:19:30 +0000 (00:19 +0900)
committerGitHub <noreply@github.com>
Sat, 3 Apr 2021 15:19:30 +0000 (00:19 +0900)
commit3b40d2c1f3ef12c602c804282ff262fd694ffbba
treec0a2eb77864e572b8859de90199856d80c578750
parent640ce99bfe70375a24c6775a937d6a258b40398b
parent5b84b9a8d8518e3db0e9f7995a54297a33c59b5c
Rollup merge of #82487 - CDirkx:const-socketaddr, r=m-ou-se

Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`

The following methods are made unstable const under the `const_socketaddr` feature (https://github.com/rust-lang/rust/issues/82485):

```rust
// std::net

impl SocketAddr {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn is_ipv4(&self) -> bool;
    pub const fn is_ipv6(&self) -> bool;
}

impl SocketAddrV4 {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
}

impl SocketAddrV6 {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn flowinfo(&self) -> u32;
    pub const fn scope_id(&self) -> u32;
}
```

Note: `SocketAddrV4::ip` and `SocketAddrV6::ip` use pointer casting and depend on the unstable feature `const_raw_ptr_deref`
library/std/src/lib.rs
library/std/src/net/addr.rs