Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Get The Domain From A URL In Rust

Code

```cargo
[dependencies]
url = "2.5.0"
```

use url::Url;

fn main() {
  let string = "https://www.example.com/";
  match Url::parse(string) {
    Ok(url) => println!("{}", url.host_str().unwrap()),
    Err(e) => println!("{}", e)
  }
}

Results

www.example.com