Rust futures
Result
Unwrap
fn get_url(name: &String) -> Result<String, i32> {
match name.as_str() {
"Google" => Ok(String::from("https://google.com")),
"Bing" => Ok(String::from("https://bing.com")),
"" => Err(1),
_ => Err(2),
}
}
fn main() {
let site: String = String::from("Google");
let url: String = get_url(&site).unwrap();
println!("Url of {} is {}", site, url);
// Url of Google is https://google.com
}