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
This is a tracking issue for adding
const fntoSocketAddr::new,SocketAddrV4::newandSocketAddrV6::newto be able to initialize the socket address at compile time, for example:Open PR: #67315