Support parsing IP addresses from a byte string by marmeladema · Pull Request #94890 · rust-lang/rust (original) (raw)

Fixes #94821

The goal is to be able to parse addresses from a byte string without requiring to do any utf8 validation. Since internally the parser already works on byte strings, this should be possible and I personally already needed this in the past too.

I used the proposed approach from the issue by implementing TryFrom<&'a [u8]> for all 6 address types (3 ip address types and 3 socket address types). I believe implementing stable traits for stable types is insta-stable so this will probably need an FCP?

Switched to an unstable inherent method approach called parse_ascii as requested.

cc @jyn514