mirror of
https://github.com/achanda/ipnetwork.git
synced 2025-06-14 16:26:32 +00:00
Cleanup mask for Ipv4Addr
This commit is contained in:

committed by
Abhishek Chanda

parent
b15eb54695
commit
432f7342e3
@ -139,11 +139,10 @@ impl Ipv4Network {
|
||||
/// let net: Ipv4Network = "127.0.0.0/16".parse().unwrap();
|
||||
/// assert_eq!(net.mask(), Ipv4Addr::new(255, 255, 0, 0));
|
||||
/// ```
|
||||
pub fn mask(self) -> Ipv4Addr {
|
||||
let prefix = self.prefix;
|
||||
let mask = !(0xffff_ffff as u64 >> prefix) as u32;
|
||||
pub fn mask(&self) -> Ipv4Addr {
|
||||
let mask = !(0xffff_ffff_u64 >> u64::from(self.prefix)) as u32;
|
||||
Ipv4Addr::from(mask)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the address of the network denoted by this `Ipv4Network`.
|
||||
/// This means the lowest possible IPv4 address inside of the network.
|
||||
|
Reference in New Issue
Block a user