Implement Default for IpNet, Ipv4Net, and Ipv6Net. Allow arithmetic_overflow panic in IpAddrRange::count().

This commit is contained in:
Kris Price
2020-03-15 18:00:37 -07:00
parent eeaea96063
commit 83cbb9b7e5
2 changed files with 8 additions and 0 deletions
+6
View File
@@ -1,5 +1,11 @@
# Releases
## Version 2.3.0 (2020-03-15)
* Merge @imp's `Default` implementation. See #18. `Ipv4Net` and `Ipv6Net` now default to 0.0.0.0/0 and ::/0 respectively. `IpNet` defaults to the 0/0 `Ipv4Net`.
* Add `#[allow(arithmetic_overflow)]` for `Ipv4AddrRange::count()` and `Ipv6AddrRange::count()`. Since 1.43.0-nightly it gives a build error but this panic behavior is desired. In future it may be replaced with explicit use of `panic!`. See #21.
## Version 2.2.0 (2020-02-02)
* Implement `From<IpAddr>`, `From<Ipv4Addr>`, and `From<Ipv6Addr>` for `IpNet`, `Ipv4Net`, and `Ipv6Net` respectively.
+2
View File
@@ -470,6 +470,7 @@ impl Iterator for Ipv4AddrRange {
}
#[allow(const_err)]
#[allow(arithmetic_overflow)]
fn count(self) -> usize {
match self.start.partial_cmp(&self.end) {
Some(Less) => {
@@ -558,6 +559,7 @@ impl Iterator for Ipv6AddrRange {
}
#[allow(const_err)]
#[allow(arithmetic_overflow)]
fn count(self) -> usize {
let count = self.count_u128();
// count fits in usize