从提供的 URL 字符串中提取主机和scheme等信息:
use url::{Url, Host, ParseError};
fn main() -> Result<(), ParseError> {
let string = "https://jdon.com"; let url = Url::parse(string)?; let scheme = url.scheme(); let host = url.host();
println!("Scheme: {}", scheme); println!("Host: {:?}", host); Ok(())
}
|