|
93 | 93 | //! [termbg]: https://docs.rs/termbg |
94 | 94 | //! [terminal-light]: https://docs.rs/terminal-light |
95 | 95 |
|
| 96 | +use cfg_if::cfg_if; |
96 | 97 | use std::time::Duration; |
97 | 98 |
|
98 | 99 | mod color; |
99 | 100 | mod error; |
100 | 101 | mod fmt; |
101 | 102 | mod os; |
102 | | -#[cfg(unix)] |
103 | | -mod xparsecolor; |
104 | 103 |
|
105 | | -#[cfg(unix)] |
106 | | -mod xterm; |
107 | | - |
108 | | -#[cfg(unix)] |
109 | | -use xterm as imp; |
110 | | - |
111 | | -#[cfg(not(unix))] |
112 | | -use unsupported as imp; |
| 104 | +cfg_if! { |
| 105 | + if #[cfg(unix)] { |
| 106 | + mod xparsecolor; |
| 107 | + mod xterm; |
| 108 | + use xterm as imp; |
| 109 | + } else { |
| 110 | + mod unsupported; |
| 111 | + use unsupported as imp; |
| 112 | + } |
| 113 | +} |
113 | 114 |
|
114 | | -#[cfg(docsrs)] |
115 | | -#[cfg_attr(docsrs, doc(cfg(docsrs)))] |
116 | | -#[doc = include_str!("../doc/terminal-survey.md")] |
117 | | -pub mod terminal_survey {} |
| 115 | +cfg_if! { |
| 116 | + if #[cfg(docsrs)] { |
| 117 | + #[doc(cfg(docsrs))] |
| 118 | + #[doc = include_str!("../doc/terminal-survey.md")] |
| 119 | + pub mod terminal_survey {} |
118 | 120 |
|
119 | | -#[cfg(docsrs)] |
120 | | -#[cfg_attr(docsrs, doc(cfg(docsrs)))] |
121 | | -#[doc = include_str!("../doc/windows.md")] |
122 | | -pub mod windows_unsupported {} |
| 121 | + #[doc(cfg(docsrs))] |
| 122 | + #[doc = include_str!("../doc/windows.md")] |
| 123 | + pub mod windows_unsupported {} |
123 | 124 |
|
124 | | -#[cfg(docsrs)] |
125 | | -#[cfg_attr(docsrs, doc(cfg(docsrs)))] |
126 | | -#[doc = include_str!("../doc/latency-rustdoc.md")] |
127 | | -pub mod latency {} |
| 125 | + #[doc(cfg(docsrs))] |
| 126 | + #[doc = include_str!("../doc/latency-rustdoc.md")] |
| 127 | + pub mod latency {} |
128 | 128 |
|
129 | | -#[cfg(docsrs)] |
130 | | -#[cfg_attr(docsrs, doc(cfg(docsrs)))] |
131 | | -#[doc = include_str!("../doc/feature-detection.md")] |
132 | | -pub mod feature_detection {} |
| 129 | + #[doc(cfg(docsrs))] |
| 130 | + #[doc = include_str!("../doc/feature-detection.md")] |
| 131 | + pub mod feature_detection {} |
| 132 | + } |
| 133 | +} |
133 | 134 |
|
134 | 135 | #[cfg(doctest)] |
135 | 136 | #[doc = include_str!("../readme.md")] |
@@ -230,23 +231,6 @@ pub fn background_color(options: QueryOptions) -> Result<Color> { |
230 | 231 | imp::background_color(options) |
231 | 232 | } |
232 | 233 |
|
233 | | -#[cfg(not(unix))] |
234 | | -mod unsupported { |
235 | | - use crate::{Color, ColorPalette, Error, QueryOptions, Result}; |
236 | | - |
237 | | - pub(crate) fn color_palette(_options: QueryOptions) -> Result<ColorPalette> { |
238 | | - Err(Error::UnsupportedTerminal) |
239 | | - } |
240 | | - |
241 | | - pub(crate) fn foreground_color(_options: QueryOptions) -> Result<Color> { |
242 | | - Err(Error::UnsupportedTerminal) |
243 | | - } |
244 | | - |
245 | | - pub(crate) fn background_color(_options: QueryOptions) -> Result<Color> { |
246 | | - Err(Error::UnsupportedTerminal) |
247 | | - } |
248 | | -} |
249 | | - |
250 | 234 | #[cfg(test)] |
251 | 235 | #[path = "color_scheme_tests.rs"] |
252 | 236 | mod tests; |
0 commit comments