fn sync_func() -> u32 {
println!("sync_func called");
42
}
async fn async_func() -> u32 {
println!("async_func called");
42
}
fn main() {
println!("Start");
let rt = tokio::runtime::Runtime::new().unwrap();
let value = sync_func();
println!("Value: {}", value);
let future = async_func();
println!("Before block");
let res =rt.block_on(future);
println!("Result: {}", res);
println!("End");
}
Start
sync_func called
Value: 42
Before block
async_func called
Result: 42
End
[package]
name = "demo"
version = "0.1.0"
edition = "2024"
[dependencies]
tokio = { version = "1.47.1", features = ["full"] }