From 723ae64fcc36d4776f043dba48f35b30876e0efd Mon Sep 17 00:00:00 2001 From: Oleksii Kachaiev Date: Fri, 23 Aug 2019 13:53:36 -0700 Subject: [PATCH] [docs] Make sure that "All Together" code compiles Added missing `spawn_and_log_error` function declaration --- docs/src/tutorial/all_together.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/src/tutorial/all_together.md b/docs/src/tutorial/all_together.md index 64fba7111..74c6987f6 100644 --- a/docs/src/tutorial/all_together.md +++ b/docs/src/tutorial/all_together.md @@ -125,6 +125,18 @@ async fn broker(mut events: Receiver) -> Result<()> { } Ok(()) } + +fn spawn_and_log_error(fut: F) -> task::JoinHandle<()> +where + F: Future> + Send + 'static, +{ + task::spawn(async move { + if let Err(e) = fut.await { + eprintln!("{}", e) + } + }) +} + ``` 1. Inside the `server`, we create the broker's channel and `task`.