Prefer ErrorKind::WouldBlock

This commit is contained in:
arthurprs
2017-09-03 18:39:04 +02:00
parent e8617ea1fc
commit f12b761b77
5 changed files with 14 additions and 20 deletions
+3 -3
View File
@@ -63,7 +63,7 @@ impl TcpListener {
match pending.poll().expect("shouldn't be canceled") {
Async::NotReady => {
self.pending_accept = Some(pending);
return Err(::would_block())
return Err(io::ErrorKind::WouldBlock.into())
},
Async::Ready(r) => return r,
}
@@ -541,7 +541,7 @@ impl ::io::Io for TcpStream {
fn read_vec(&mut self, bufs: &mut [&mut IoVec]) -> io::Result<usize> {
if let Async::NotReady = <TcpStream>::poll_read(self) {
return Err(::would_block())
return Err(io::ErrorKind::WouldBlock.into())
}
let r = self.io.get_ref().read_bufs(bufs);
if is_wouldblock(&r) {
@@ -552,7 +552,7 @@ impl ::io::Io for TcpStream {
fn write_vec(&mut self, bufs: &[&IoVec]) -> io::Result<usize> {
if let Async::NotReady = <TcpStream>::poll_write(self) {
return Err(::would_block())
return Err(io::ErrorKind::WouldBlock.into())
}
let r = self.io.get_ref().write_bufs(bufs);
if is_wouldblock(&r) {
+2 -2
View File
@@ -101,7 +101,7 @@ impl UdpSocket {
/// documentation for concrete examples.
pub fn send_to(&self, buf: &[u8], target: &SocketAddr) -> io::Result<usize> {
if let Async::NotReady = self.io.poll_write() {
return Err(::would_block())
return Err(io::ErrorKind::WouldBlock.into())
}
match self.io.get_ref().send_to(buf, target) {
Ok(n) => Ok(n),
@@ -145,7 +145,7 @@ impl UdpSocket {
/// read and the address from whence the data came.
pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
if let Async::NotReady = self.io.poll_read() {
return Err(::would_block())
return Err(io::ErrorKind::WouldBlock.into())
}
match self.io.get_ref().recv_from(buf) {
Ok(n) => Ok(n),