Closed
Description
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
Metadata
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Area: `std::io`, `std::fs`, `std::net` and `std::path`Category: An issue tracking the progress of sth. like the implementation of an RFCLibs issues that are tracked on the team's project board.Status: Blocked on something else such as an RFC or other implementation work.Relevant to the library API team, which will review and decide on the PR/issue.