Skip to content

Commit

Permalink
make example more interesting
Browse files Browse the repository at this point in the history
  • Loading branch information
jswrenn committed Oct 19, 2022
1 parent ad8fcf1 commit 94b96c7
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions backtrace/examples/taskdump.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
// This example prints something like:
// ╼ taskdump::foo::{{closure}} at backtrace/examples/taskdump.rs:12:1
// └╼ taskdump::bar::{{closure}} at backtrace/examples/taskdump.rs:17:1
// └╼ taskdump::buz::{{closure}} at backtrace/examples/taskdump.rs:27:1
// ╼ taskdump::baz::{{closure}} at backtrace/examples/taskdump.rs:32:1
// This example outputs something like:
// ╼ taskdump::foo::{{closure}} at backtrace/examples/taskdump.rs:20:1
// └╼ taskdump::bar::{{closure}} at backtrace/examples/taskdump.rs:25:1
// ├╼ taskdump::buz::{{closure}} at backtrace/examples/taskdump.rs:35:1
// │ └╼ taskdump::baz::{{closure}} at backtrace/examples/taskdump.rs:40:1
// └╼ taskdump::fiz::{{closure}} at backtrace/examples/taskdump.rs:30:1
// ╼ taskdump::pending::{{closure}} at backtrace/examples/taskdump.rs:15:1

#[tokio::main]
async fn main() {
foo().await;
tokio::select! {
_ = tokio::spawn(pending()) => {}
_ = foo() => {}
};
}

#[async_backtrace::framed]
async fn pending() {
std::future::pending::<()>().await
}

#[async_backtrace::framed]
Expand All @@ -26,7 +36,7 @@ async fn fiz() {

#[async_backtrace::framed]
async fn buz() {
println!("{}", tokio::spawn(baz()).await.unwrap());
println!("{}", baz().await);
}

#[async_backtrace::framed]
Expand Down

0 comments on commit 94b96c7

Please sign in to comment.