
Rust: Parse a URL
Parsing a URL into its contituent parts is possible via url
crate:
use url::Url;
fn main() {
let url = "https://alice:secrets@glenngillen.com:8080/foo?q=bar#baz";
let parts = Url::parse(url).expect("Unable to parse URL");
println!("{}", parts.scheme());
println!("{}", parts.username());
println!("{}", parts.password().expect("no password"));
println!("{}", parts.host_str().expect("no host"));
println!("{}", parts.port().expect("no port"));
println!("{}", parts.path());
println!("{}", parts.query().expect("no query"));
println!("{}", parts.fragment().expect("no fragment"));
}
Published: 25/03/2022
Hi, I'm Glenn! 👋
I've spent most of my career working with or at startups. You'll usually find me working in Product leadership roles, on an advisory board, or maybe as an early investor.
I've been the VP of Product & GTM @ Ockam. I led the Terraform product team @ HashiCorp, where we launched Terraform 1.0, Terraform Cloud, and a whole host of amazing capabilities that set the stage for a successful IPO. Prior to that I was part of the Startup Team @ AWS, and earlier still an early employee @ Heroku. I've also invested in a couple of dozen early stage startups.
I've spent most of my career working with or at startups. You'll usually find me working in Product leadership roles, on an advisory board, or maybe as an early investor.
I've been the VP of Product & GTM @ Ockam. I led the Terraform product team @ HashiCorp, where we launched Terraform 1.0, Terraform Cloud, and a whole host of amazing capabilities that set the stage for a successful IPO. Prior to that I was part of the Startup Team @ AWS, and earlier still an early employee @ Heroku. I've also invested in a couple of dozen early stage startups.