mirror of https://github.com/stjepang/smol
Remove let _ pattern
This commit is contained in:
parent
7d19c85172
commit
c9a8a955b0
|
@ -57,7 +57,7 @@ async fn dispatch(receiver: Receiver<Event>) -> 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<Event>, client: Arc<Async<TcpStream>>) ->
|
|||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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!");
|
||||
})
|
||||
|
|
|
@ -18,7 +18,7 @@ const ROOT: &str = "https://www.rust-lang.org";
|
|||
async fn fetch(url: String, sender: Sender<String>) {
|
||||
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.
|
||||
|
|
|
@ -114,9 +114,8 @@ pub fn spawn<T: Send + 'static>(future: impl Future<Output = T> + 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");
|
||||
|
|
Loading…
Reference in New Issue