Skip to content
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

const fn for SocketAddr::new, SocketAddrV4::new and SocketAddrV6::new #67390

Closed
gliderkite opened this issue Dec 18, 2019 · 5 comments
Closed
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. Libs-Tracked Libs issues that are tracked on the team's project board. S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@gliderkite
Copy link

This is a tracking issue for adding const fn to SocketAddr::new, SocketAddrV4::new and SocketAddrV6::new to be able to initialize the socket address at compile time, for example:

use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6, SocketAddr};

const localhost_v4: Ipv4Addr = Ipv4Addr::new(127, 0, 0, 1);
const socket_v4: SocketAddrV4 = SocketAddrV4::new(localhost_v4, 80);
const socket_add_v4: SocketAddr = SocketAddr::new(IpAddr::V4(localhost_v4), 80);

const localhost_v6: Ipv6Addr = Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1);
const socket_v6: SocketAddrV6 = SocketAddrV6::new(localhost_v6, 80, 0, 0);
const socket_add_v6: SocketAddr = SocketAddr::new(IpAddr::V6(localhost_v6), 80);

Open PR: #67315

@jonas-schievink jonas-schievink added A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Dec 18, 2019
@KodrAus KodrAus added Libs-Tracked Libs issues that are tracked on the team's project board. A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` labels Jul 30, 2020
@DCjanus
Copy link

DCjanus commented Oct 1, 2020

ping

@gliderkite
Copy link
Author

@DCjanus This is probably still blocked on some open issues, such as #67792.

@l3utterfly
Copy link

Ping. This feature would really be helpful.

@faern
Copy link
Contributor

faern commented Aug 11, 2021

It would! But it's currently blocked on #78802

@Mark-Simulacrum
Copy link
Member

I believe these are all done as of ~1.69. In general there's not much value in a tracking issue vs. filing a PR if there's no blockers to stabilize as well, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. Libs-Tracked Libs issues that are tracked on the team's project board. S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants