4

Github Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAdd...

 3 years ago
source link: https://github.com/rust-lang/rust/pull/82487
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Contributor

CDirkx commented on Feb 24

edited

The following methods are made unstable const under the const_socketaddr feature (#82485):

// 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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK