Add code for running the async functions

This commit is contained in:
Manuel Thalmann 2025-04-03 20:50:08 +02:00
parent 6e852c6c60
commit 9e59d39384
Signed by: manuth
SSH key fingerprint: SHA256:HsMLC+7kJWALP6YCYCoopxNbUnghwSGLVcG76SECT5c

View file

@ -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> {