Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdded FromStr impl and tests for HostAndPort #264
Conversation
|
I’m somewhat hesitant to take this since there might be subtle variations of the exact parsing algorithm, and the URL Standard doesn’t specify one. The closest thing would be the setter of the Which brings the most important question: why do you want this? In what context would you use it? Is there a spec with a parsing algorithm or grammar? |
|
The reason I want this is that I need to pass around a network address, but without the IP address resolved as it is with The only issue is that it is a bit unwieldy to construct a let addr = HostAndPort {
host: Host::Domain("localhost"), port: 80,
};into let addr: HostAndPort = "localhost:80".parse().unwrap();Unfortunately, I do not know of any specification for parsing. But with my rudimentary knowledge of URLs, just chopping off everything after the last Another option to this would a let addr = HostAndPort::new("localhost", 80);but there would still have to be an I'm not sure which way would be best. Your thoughts? |
It sounds like you just want a simple constructor, but I’d recommend making your own type and a constructor method for them. Parsing the host part could be something along the lines of "try But come to think of it, do you even need to parse IP addresses? Could you pass around |
dtolnay
commented
May 12, 2017
|
Given that there is no spec with a parsing algorithm or grammar, we are not planning to provide this functionality in |
|
Closing for lack of response from @amikhalev about what exactly is desired. |
amikhalev commentedDec 28, 2016
•
edited by larsbergstrom
This change is