Make IpNetwork::ip const (#212)

This commit is contained in:
Markus Pettersson
2025-01-09 00:38:34 +01:00
committed by GitHub
parent a21f5df04e
commit 5f929258ef
3 changed files with 3 additions and 3 deletions

View File

@ -140,7 +140,7 @@ impl Ipv4Network {
}
}
pub fn ip(self) -> Ipv4Addr {
pub const fn ip(self) -> Ipv4Addr {
self.addr
}

View File

@ -160,7 +160,7 @@ impl Ipv6Network {
}
}
pub fn ip(&self) -> Ipv6Addr {
pub const fn ip(&self) -> Ipv6Addr {
self.addr
}

View File

@ -141,7 +141,7 @@ impl IpNetwork {
}
/// Returns the IP part of a given `IpNetwork`
pub fn ip(&self) -> IpAddr {
pub const fn ip(&self) -> IpAddr {
match *self {
IpNetwork::V4(ref a) => IpAddr::V4(a.ip()),
IpNetwork::V6(ref a) => IpAddr::V6(a.ip()),