krisprice / ipnet

IpNet, Ipv4Net, and Ipv6Net types and methods for Rust
Apache License 2.0
122 stars 26 forks source link

add convenience `IpNet::new` method #36

Closed mcginty closed 2 years ago

mcginty commented 2 years ago

This is a convenience to avoid having extra match statements in the code of consumers of this crate that, like in my case, are receiving an IpAddr and prefix and would like to build a network out of that information.

Since the FromStr implementation is essentially the same situation and validation of prefix length is still handled appropriately, it would make sense for this method to exist in my opinion.

krisprice commented 2 years ago

Thanks!