How to use url crate in Rust URL parsing

Add the url crate to Cargo.toml and use Url::parse() to extract scheme, host, and path from a string.

Add the url crate to your Cargo.toml and parse strings using Url::parse().

[dependencies]
url = "2.5"
use url::Url;

fn main() {
    let url = Url::parse("https://example.com/path?query=1").unwrap();
    println!("Scheme: {}", url.scheme());
    println!("Host: {}", url.host_str().unwrap());
    println!("Path: {}", url.path());
}