mirror of
https://github.com/quantum5/ntfy-run.git
synced 2025-04-24 05:31:58 -04:00
Use simpler else clause with tokio::select!
This commit is contained in:
parent
765f3e6bd3
commit
5a464aa3b1
|
@ -61,29 +61,20 @@ pub async fn run_forward_and_capture(cmdline: &Vec<String>) -> CapturedOutput {
|
|||
result = stdout_tap.step(), if !stdout_eof => match result {
|
||||
Ok(ReadOrWrite::Read(bytes)) => stdout.extend_from_slice(bytes),
|
||||
Ok(ReadOrWrite::Written) => (),
|
||||
Ok(ReadOrWrite::EOF) => match (stderr_eof, maybe_status) {
|
||||
(true, Some(status)) => break status,
|
||||
_ => stdout_eof = true,
|
||||
},
|
||||
Ok(ReadOrWrite::EOF) => stdout_eof = true,
|
||||
Err(error) => errors.push(CaptureError::Stdout(error)),
|
||||
},
|
||||
result = stderr_tap.step(), if !stderr_eof => match result {
|
||||
Ok(ReadOrWrite::Read(bytes)) => stderr.extend_from_slice(bytes),
|
||||
Ok(ReadOrWrite::Written) => (),
|
||||
Ok(ReadOrWrite::EOF) => match (stdout_eof, maybe_status) {
|
||||
(true, Some(status)) => break status,
|
||||
_ => stderr_eof = true,
|
||||
},
|
||||
Ok(ReadOrWrite::EOF) => stderr_eof = true,
|
||||
Err(error) => errors.push(CaptureError::Stderr(error)),
|
||||
},
|
||||
status = child.wait(), if maybe_status.is_none() => match status {
|
||||
Ok(status) => if stdout_eof && stderr_eof {
|
||||
break status;
|
||||
} else {
|
||||
maybe_status = Some(status);
|
||||
},
|
||||
Ok(status) => maybe_status = Some(status),
|
||||
Err(error) => errors.push(CaptureError::Wait(error)),
|
||||
}
|
||||
},
|
||||
else => break maybe_status.unwrap(),
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -34,11 +34,11 @@ impl<R: AsyncRead + Unpin, W: AsyncWrite + Unpin> TapStream<R, W> {
|
|||
self.buf_start = 0;
|
||||
self.buf_end = bytes;
|
||||
|
||||
Ok(if bytes == 0 {
|
||||
ReadOrWrite::EOF
|
||||
if bytes == 0 {
|
||||
Ok(ReadOrWrite::EOF)
|
||||
} else {
|
||||
ReadOrWrite::Read(&self.buffer[0..bytes])
|
||||
})
|
||||
Ok(ReadOrWrite::Read(&self.buffer[0..bytes]))
|
||||
}
|
||||
} else {
|
||||
let bytes = self
|
||||
.target
|
||||
|
|
Loading…
Reference in a new issue