From 9e59d3938485d1a5f0cc51dbfd986d8f5c6ec92c Mon Sep 17 00:00:00 2001 From: Manuel Thalmann <m@nuth.ch> Date: Thu, 3 Apr 2025 20:50:08 +0200 Subject: [PATCH] Add code for running the async functions --- hello-async/src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hello-async/src/main.rs b/hello-async/src/main.rs index 6bc2e81..a42a94e 100644 --- a/hello-async/src/main.rs +++ b/hello-async/src/main.rs @@ -1,7 +1,15 @@ use trpl::Html; fn main() { - println!("Hello, world!"); + let args: Vec<String> = std::env::args().collect(); + + trpl::run(async { + let url = &args[1]; + match page_title(url).await { + Some(title) => println!("The title for {url} was {title}"), + None => println!("{url} had no title"), + } + }) } async fn page_title(url: &str) -> Option<String> {