Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Allow parsing of abbreviated IPv4 CIDR addresses #22

Open
darrinsmart opened this issue Jun 6, 2020 · 2 comments
Open

Comments

@darrinsmart
Copy link

This works:
let net4 = Ipv4Net::from_str("10.1.1.0/24").unwrap();

But this doesn't:
let net4 = Ipv4Net::from_str("10.1.1/24").unwrap();

This abbreviated form of IPv4 CIDR - omitting trailing 0 octets, is fairly common, it would be great if ipnet could accept these.

@krisprice
Copy link
Owner

HI @darrinsmart -- I'll keep this issue around to track and when I have time implement this. Thanks 👍

@benmaddison
Copy link

@krisprice although I can appreciate that this might be useful in some applications, it will break others if it's done silently in the FromStr impls. There are plenty of places (e.g. most vendor config syntaxes, RPSL) were the abbreviated form is not legal.
I'd suggest a separate constructor for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants