Skip to content

Commit 5e2264f

Browse files
committed
Correctly gate shared code
1 parent 02f82b0 commit 5e2264f

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

src/os/macos/poll.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::super::PollReadTimedOutError;
1+
use crate::os::unix_common::timed_out;
22
use libc::{c_int, pselect, time_t, timespec, FD_ISSET, FD_SET};
33
use std::io;
44
use std::mem::zeroed;
@@ -54,7 +54,3 @@ fn to_io_result(value: c_int) -> io::Result<c_int> {
5454
Ok(value)
5555
}
5656
}
57-
58-
fn timed_out() -> io::Error {
59-
io::Error::new(io::ErrorKind::TimedOut, PollReadTimedOutError)
60-
}

src/os/mod.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use std::error::Error;
2-
use std::fmt;
3-
41
#[cfg(target_os = "macos")]
52
mod macos;
63
#[cfg(target_os = "macos")]
@@ -9,14 +6,5 @@ pub(crate) use macos::*;
96
mod unix;
107
#[cfg(all(unix, not(target_os = "macos")))]
118
pub(crate) use unix::*;
12-
13-
#[derive(Debug)]
14-
struct PollReadTimedOutError;
15-
16-
impl fmt::Display for PollReadTimedOutError {
17-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18-
write!(f, "poll_read timed out")
19-
}
20-
}
21-
22-
impl Error for PollReadTimedOutError {}
9+
#[cfg(unix)]
10+
mod unix_common;

src/os/unix/poll.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::super::PollReadTimedOutError;
1+
use crate::os::unix_common::timed_out;
22
use mio::unix::SourceFd;
33
use mio::{Events, Interest, Poll, Token};
44
use std::io;
@@ -26,7 +26,3 @@ pub(crate) fn poll_read(terminal: BorrowedFd, timeout: Duration) -> io::Result<(
2626
}
2727
Err(timed_out())
2828
}
29-
30-
fn timed_out() -> io::Error {
31-
io::Error::new(io::ErrorKind::TimedOut, PollReadTimedOutError)
32-
}

src/os/unix_common.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use std::error::Error;
2+
use std::{fmt, io};
3+
4+
pub(crate) fn timed_out() -> io::Error {
5+
io::Error::new(io::ErrorKind::TimedOut, PollReadTimedOutError)
6+
}
7+
8+
#[derive(Debug)]
9+
struct PollReadTimedOutError;
10+
11+
impl fmt::Display for PollReadTimedOutError {
12+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13+
write!(f, "poll_read timed out")
14+
}
15+
}
16+
17+
impl Error for PollReadTimedOutError {}

0 commit comments

Comments
 (0)