-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Constify methods of std::net::SocketAddr
, SocketAddrV4
and SocketAddrV6
#82487
Conversation
…tAddrV6` The following methods are made unstable const under the `const_socketaddr` feature: `SocketAddr` - `ip` - `port` - `is_ipv4` - `is_ipv6` `SocketAddrV4` - `ip` - `port` `SocketAddrV6` - `ip` - `port` - `flowinfo` - `scope_id`
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
@rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
This PR makes the methods unstably const, but since there is already an FCP shall I just make them stable const? This PR also doesnt include |
@CDirkx @joshtriplett Hmmm, yeah I don't think we usually do an FCP for small unstable API additions. I think we do generally want APIs to bake on unstable for a bit before stabilizing them though. Maybe we should just cancel this FCP and merge the PR for now? |
@m-ou-se proposal cancelled. |
📌 Commit 5b84b9a has been approved by |
Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6` The following methods are made unstable const under the `const_socketaddr` feature (rust-lang#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`
Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6` The following methods are made unstable const under the `const_socketaddr` feature (rust-lang#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`
Rollup of 7 pull requests Successful merges: - rust-lang#82487 (Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`) - rust-lang#83756 (rustdoc: Rename internal uses of `spotlight`) - rust-lang#83780 (Document "standard" conventions for error messages) - rust-lang#83787 (Monomorphization doc fix) - rust-lang#83803 (add fp-armv8 for ARM_ALLOWED_FEATURES) - rust-lang#83804 (Remove nightly features in rustc_type_ir) - rust-lang#83810 (Fix rustc_lint_defs documentation typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
The following methods are made unstable const under the
const_socketaddr
feature (#82485):Note:
SocketAddrV4::ip
andSocketAddrV6::ip
use pointer casting and depend on the unstable featureconst_raw_ptr_deref