From 2b60abca1dfa016e2becbb497709eb220eb626d7 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Fri, 23 Aug 2019 12:51:02 -0700 Subject: [PATCH] Add back in std-only trait definitions Fixes #96 --- src/lib.rs | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 06b89912..023a6230 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -159,27 +159,21 @@ pub use crate::error::Error; #[allow(dead_code)] mod util; -// Unlike the other Unix, Fuchsia and iOS don't use the libc to make any calls. -#[cfg(any( - target_os = "android", - target_os = "dragonfly", - target_os = "emscripten", - target_os = "freebsd", - target_os = "haiku", - target_os = "illumos", - target_os = "linux", - target_os = "macos", - target_os = "netbsd", - target_os = "openbsd", - target_os = "redox", - target_os = "solaris", -))] -#[allow(dead_code)] -mod util_libc; -// std-only trait definitions -#[cfg(feature = "std")] -mod error_impls; +cfg_if! { + // Unlike the other Unix, Fuchsia and iOS don't use the libc to make any calls. + if #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "emscripten", + target_os = "freebsd", target_os = "haiku", target_os = "illumos", + target_os = "linux", target_os = "macos", target_os = "netbsd", + target_os = "openbsd", target_os = "redox", target_os = "solaris"))] { + #[allow(dead_code)] + mod util_libc; + // Keep std-only trait definitions for backwards compatiblity + mod error_impls; + } else if #[cfg(feature = "std")] { + mod error_impls; + } +} // These targets read from a file as a fallback method. #[cfg(any(