diff --git a/examples/chat-server.rs b/examples/chat-server.rs index 99a8048..c282dd2 100644 --- a/examples/chat-server.rs +++ b/examples/chat-server.rs @@ -57,7 +57,7 @@ async fn dispatch(receiver: Receiver) -> io::Result<()> { // Send the event to all active clients. for stream in map.values_mut() { // Ignore errors because the client might disconnect at any point. - let _ = stream.write_all(output.as_bytes()).await; + stream.write_all(output.as_bytes()).await.ok(); } } Ok(()) @@ -70,7 +70,7 @@ async fn read_messages(sender: Sender, client: Arc>) -> while let Some(line) = lines.next().await { let line = line?; - let _ = sender.send(Event::Message(addr, line)).await; + sender.send(Event::Message(addr, line)).await.ok(); } Ok(()) } @@ -97,13 +97,13 @@ fn main() -> io::Result<()> { // Spawn a background task reading messages from the client. smol::spawn(async move { // Client starts with a `Join` event. - let _ = sender.send(Event::Join(addr, client.clone())).await; + sender.send(Event::Join(addr, client.clone())).await.ok(); // Read messages from the client and ignore I/O errors when the client quits. - let _ = read_messages(sender.clone(), client).await; + read_messages(sender.clone(), client).await.ok(); // Client ends with a `Leave` event. - let _ = sender.send(Event::Leave(addr)).await; + sender.send(Event::Leave(addr)).await.ok(); }) .detach(); } diff --git a/examples/ctrl-c.rs b/examples/ctrl-c.rs index ecc412a..9060d86 100644 --- a/examples/ctrl-c.rs +++ b/examples/ctrl-c.rs @@ -18,7 +18,7 @@ fn main() { println!("Waiting for Ctrl-C..."); // Receive a message that indicates the Ctrl-C signal occurred. - let _ = ctrl_c.recv().await; + ctrl_c.recv().await.ok(); println!("Done!"); }) diff --git a/examples/web-crawler.rs b/examples/web-crawler.rs index 8aa5adb..2ec6292 100644 --- a/examples/web-crawler.rs +++ b/examples/web-crawler.rs @@ -18,7 +18,7 @@ const ROOT: &str = "https://www.rust-lang.org"; async fn fetch(url: String, sender: Sender) { let body = surf::get(&url).recv_string().await; let body = body.unwrap_or_default(); - let _ = sender.send(body).await; + sender.send(body).await.ok(); } /// Extracts links from a HTML body. diff --git a/src/lib.rs b/src/lib.rs index bba4dd2..1e2fa43 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -114,9 +114,8 @@ pub fn spawn(future: impl Future + Send + 'static .name(format!("smol-{}", n)) .spawn(|| { loop { - let _ = catch_unwind(|| { - async_io::block_on(GLOBAL.run(future::pending::<()>())) - }); + catch_unwind(|| async_io::block_on(GLOBAL.run(future::pending::<()>()))) + .ok(); } }) .expect("cannot spawn executor thread");