From 1c66a1c770f70cb15811adcb3de12ae67d87b6a1 Mon Sep 17 00:00:00 2001 From: AzureMarker Date: Mon, 24 Jan 2022 17:27:18 -0800 Subject: [PATCH] Use cfg-if --- ctru-rs/Cargo.toml | 1 + ctru-rs/src/lib.rs | 31 +++++++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/ctru-rs/Cargo.toml b/ctru-rs/Cargo.toml index 5e29ef1..24f1efa 100644 --- a/ctru-rs/Cargo.toml +++ b/ctru-rs/Cargo.toml @@ -11,6 +11,7 @@ crate-type = ["rlib"] name = "ctru" [dependencies] +cfg-if = "1.0" ctru-sys = { path = "../ctru-sys", version = "0.4" } const-zero = "0.1.0" linker-fix-3ds = { git = "https://github.com/Meziu/rust-linker-fix-3ds.git" } diff --git a/ctru-rs/src/lib.rs b/ctru-rs/src/lib.rs index 6669c60..23be6b8 100644 --- a/ctru-rs/src/lib.rs +++ b/ctru-rs/src/lib.rs @@ -37,20 +37,23 @@ pub mod services; pub mod srv; pub mod thread; -#[cfg(all(feature = "romfs", romfs_exists))] -pub mod romfs; -#[cfg(not(all(feature = "romfs", romfs_exists)))] -pub mod romfs { - //! The RomFS folder has not been detected and/or the `romfs` feature has not been enabled. - //! - //! Configure the path in Cargo.toml (the default path is "romfs"). Paths are relative to the - //! `CARGO_MANIFEST_DIR` environment variable, which is the directory containing the manifest of - //! your package. - //! - //! ```toml - //! [package.metadata.cargo-3ds] - //! romfs_dir = "romfs" - //! ``` +cfg_if::cfg_if! { + if #[cfg(all(feature = "romfs", romfs_exists))] { + pub mod romfs; + } else { + pub mod romfs { + //! The RomFS folder has not been detected and/or the `romfs` feature has not been enabled. + //! + //! Configure the path in Cargo.toml (the default path is "romfs"). Paths are relative to the + //! `CARGO_MANIFEST_DIR` environment variable, which is the directory containing the manifest of + //! your package. + //! + //! ```toml + //! [package.metadata.cargo-3ds] + //! romfs_dir = "romfs" + //! ``` + } + } } pub use crate::error::{Error, Result};