Unwrap channel send()

This commit is contained in:
Edwin Cheng 2020-03-31 21:24:10 +08:00
parent 7f7a16675d
commit e7d1549e13

View file

@ -31,7 +31,7 @@ struct SenderGuard(pub Sender<Task>);
impl std::ops::Drop for SenderGuard { impl std::ops::Drop for SenderGuard {
fn drop(&mut self) { fn drop(&mut self) {
let _ = self.0.send(Task::Close); self.0.send(Task::Close).unwrap();
} }
} }
@ -126,12 +126,7 @@ impl ProcMacroProcessSrv {
let (result_tx, result_rx) = bounded(0); let (result_tx, result_rx) = bounded(0);
sender.send(Task::Request { req: req.into(), result_tx }).map_err(|err| { sender.send(Task::Request { req: req.into(), result_tx }).unwrap();
ra_tt::ExpansionError::Unknown(format!(
"Fail to send task in channel, reason : {:#?} ",
err
))
})?;
let res = result_rx.recv().unwrap(); let res = result_rx.recv().unwrap();
match res { match res {
@ -172,9 +167,7 @@ fn client_loop(task_rx: Receiver<Task>, mut process: Process) {
code: ErrorCode::ServerErrorEnd, code: ErrorCode::ServerErrorEnd,
message: "Server closed".into(), message: "Server closed".into(),
}); });
if result_tx.send(res.into()).is_err() { result_tx.send(res.into()).unwrap();
break;
}
// Restart the process // Restart the process
if process.restart().is_err() { if process.restart().is_err() {
break; break;
@ -190,9 +183,7 @@ fn client_loop(task_rx: Receiver<Task>, mut process: Process) {
}; };
if let Some(res) = res { if let Some(res) = res {
if result_tx.send(res).is_err() { result_tx.send(res).unwrap();
break;
}
} }
} }