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

committed by
Abhishek Chanda

parent
a96f30d64e
commit
ec79428c75
@ -215,9 +215,8 @@ impl Ipv4Network {
|
||||
/// assert_eq!(tinynet.size(), 1);
|
||||
/// ```
|
||||
pub fn size(self) -> u32 {
|
||||
let host_bits = u32::from(IPV4_BITS - self.prefix);
|
||||
(2 as u32).pow(host_bits)
|
||||
}
|
||||
1 << (u32::from(IPV4_BITS - self.prefix))
|
||||
}
|
||||
|
||||
/// Returns the `n`:th address within this network.
|
||||
/// The adresses are indexed from 0 and `n` must be smaller than the size of the network.
|
||||
|
@ -242,7 +242,7 @@ impl Ipv6Network {
|
||||
/// ```
|
||||
pub fn size(&self) -> u128 {
|
||||
let host_bits = u32::from(IPV6_BITS - self.prefix);
|
||||
(2 as u128).pow(host_bits)
|
||||
2u128.pow(host_bits)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user