aboutsummaryrefslogtreecommitdiffstats
path: root/src/rw.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/rw.rs')
-rw-r--r--src/rw.rs31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/rw.rs b/src/rw.rs
index 96031cc..601a2ec 100644
--- a/src/rw.rs
+++ b/src/rw.rs
@@ -133,17 +133,17 @@ fn check<'a>(
return PollStatus::Cancel;
};
- if let Some(event) = poll_fds[0].revents() {
- if event.contains(PollFlags::POLLIN) {
- canceled.store(true, SeqCst);
- return PollStatus::Cancel;
- }
+ if let Some(event) = poll_fds[0].revents()
+ && event.contains(PollFlags::POLLIN)
+ {
+ canceled.store(true, SeqCst);
+ return PollStatus::Cancel;
}
- if let Some(event) = poll_fds[1].revents() {
- if event.contains(flags) {
- return PollStatus::Ready;
- }
+ if let Some(event) = poll_fds[1].revents()
+ && event.contains(flags)
+ {
+ return PollStatus::Ready;
}
PollStatus::Wait
@@ -157,7 +157,7 @@ impl InputReader {
Input::Pipe(pipe) => pipe.as_fd(),
Input::File(file) => file.as_fd(),
};
- check(&*self.canceled, &self.cancel, read_fd, PollFlags::POLLIN)
+ check(&self.canceled, &self.cancel, read_fd, PollFlags::POLLIN)
}
}
@@ -176,7 +176,7 @@ impl Read for InputReader {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
loop {
match self.poll() {
- PollStatus::Cancel => return Err(io::Error::new(io::ErrorKind::Other, Canceled)),
+ PollStatus::Cancel => return Err(io::Error::other(Canceled)),
PollStatus::Ready => (),
PollStatus::Wait => continue,
}
@@ -214,12 +214,7 @@ impl OutputWriter {
Output::Pipe(pipe) => pipe.as_fd(),
Output::File(file) => file.as_fd(),
};
- check(
- &mut self.canceled,
- &self.cancel,
- write_fd,
- PollFlags::POLLOUT,
- )
+ check(&self.canceled, &self.cancel, write_fd, PollFlags::POLLOUT)
}
pub fn try_clone(&self) -> io::Result<Self> {
let output = self.output.try_clone()?;
@@ -237,7 +232,7 @@ impl Write for OutputWriter {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
loop {
match self.poll() {
- PollStatus::Cancel => return Err(io::Error::new(io::ErrorKind::Other, Canceled)),
+ PollStatus::Cancel => return Err(io::Error::other(Canceled)),
PollStatus::Ready => (),
PollStatus::Wait => continue,
}