Closed mcginty closed 3 years ago
Thanks @mcginty I think the case where the two IP versions do not match should result in an error, to make the API less confusing. I'd add a new error type here https://github.com/achanda/ipnetwork/blob/master/src/common.rs#L5 and also add some tests. What do you think?
In my application, the current API is simpler to read while still being technically correct.
As an alternative to the idea of having these methods return a Result<bool, IpNetworkError>
, would it possibly be nicer to instead add another fn is_same_ip_version(other: IpNetwork) -> bool
so people can do if net1.is_same_ip_version(net2) && net1.is_supernet_of(net2)
if they care to distinguish?
Very similar to the implementations for
contains()
that's already in theIpNetwork
enum.