forked from mirror/async-std
[docs] Make sure that "All Together" code compiles (#104)
Added missing `spawn_and_log_error` function declaration
This commit is contained in:
parent
6d6328a9c8
commit
34802cae7e
1 changed files with 12 additions and 0 deletions
|
@ -125,6 +125,18 @@ async fn broker(mut events: Receiver<Event>) -> Result<()> {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn spawn_and_log_error<F>(fut: F) -> task::JoinHandle<()>
|
||||
where
|
||||
F: Future<Output = Result<()>> + 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`.
|
||||
|
|
Loading…
Reference in a new issue