mirror of
https://github.com/openharmony/third_party_rust_ipnet.git
synced 2026-07-01 20:24:06 -04:00
Implement Default for IpNet, Ipv4Net, and Ipv6Net. Allow arithmetic_overflow panic in IpAddrRange::count().
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user