Skip to content

Commit 49f07a4

Browse files
Make IpNetwork::prefix const (#209)
1 parent 2f219a2 commit 49f07a4

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/ipv4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl Ipv4Network {
144144
self.addr
145145
}
146146

147-
pub fn prefix(self) -> u8 {
147+
pub const fn prefix(self) -> u8 {
148148
self.prefix
149149
}
150150

src/ipv6.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl Ipv6Network {
164164
self.addr
165165
}
166166

167-
pub fn prefix(&self) -> u8 {
167+
pub const fn prefix(&self) -> u8 {
168168
self.prefix
169169
}
170170

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl IpNetwork {
160160
/// assert_eq!(IpNetwork::V6("ff01::0".parse().unwrap()).prefix(), 128u8);
161161
/// assert_eq!(IpNetwork::V6("ff01::0/32".parse().unwrap()).prefix(), 32u8);
162162
/// ```
163-
pub fn prefix(&self) -> u8 {
163+
pub const fn prefix(&self) -> u8 {
164164
match *self {
165165
IpNetwork::V4(ref a) => a.prefix(),
166166
IpNetwork::V6(ref a) => a.prefix(),

0 commit comments

Comments
 (0)