From 34802cae7eb93d39bbbef54ae0c443c01cb8edf8 Mon Sep 17 00:00:00 2001 From: Oleksii Kachaiev Date: Fri, 23 Aug 2019 17:17:12 -0700 Subject: [PATCH] [docs] Make sure that "All Together" code compiles (#104) 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 64fba71..74c6987 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`.