diff --git a/src/ipv4.rs b/src/ipv4.rs index 5906ef0..15b46d9 100644 --- a/src/ipv4.rs +++ b/src/ipv4.rs @@ -144,7 +144,7 @@ impl Ipv4Network { self.addr } - pub fn prefix(self) -> u8 { + pub const fn prefix(self) -> u8 { self.prefix } diff --git a/src/ipv6.rs b/src/ipv6.rs index 2767471..9e70371 100644 --- a/src/ipv6.rs +++ b/src/ipv6.rs @@ -164,7 +164,7 @@ impl Ipv6Network { self.addr } - pub fn prefix(&self) -> u8 { + pub const fn prefix(&self) -> u8 { self.prefix } diff --git a/src/lib.rs b/src/lib.rs index 491e7c3..6bc6cb1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -160,7 +160,7 @@ impl IpNetwork { /// assert_eq!(IpNetwork::V6("ff01::0".parse().unwrap()).prefix(), 128u8); /// assert_eq!(IpNetwork::V6("ff01::0/32".parse().unwrap()).prefix(), 32u8); /// ``` - pub fn prefix(&self) -> u8 { + pub const fn prefix(&self) -> u8 { match *self { IpNetwork::V4(ref a) => a.prefix(), IpNetwork::V6(ref a) => a.prefix(),