1
1
//! Types and constants for handling humidity.
2
2
3
3
use super :: measurement:: * ;
4
+ #[ cfg( not( feature = "no_std" ) ) ]
4
5
use density:: Density ;
6
+ #[ cfg( not( feature = "no_std" ) ) ]
5
7
use pressure:: Pressure ;
8
+ #[ cfg( not( feature = "no_std" ) ) ]
6
9
use temperature:: Temperature ;
7
10
8
11
/// The `Humidity` struct can be used to deal with relative humidity
@@ -32,7 +35,9 @@ use temperature::Temperature;
32
35
///
33
36
/// let humidity = Humidity::from_percent(85.0);
34
37
/// let temp = Temperature::from_celsius(18.0);
38
+ /// #[cfg(not(feature="no_std"))]
35
39
/// let dewpoint = humidity.as_dewpoint(temp);
40
+ /// #[cfg(not(feature="no_std"))]
36
41
/// println!("At {} humidity, air at {} has a dewpoint of {}", humidity, temp, dewpoint);
37
42
///
38
43
/// ```
@@ -162,41 +167,47 @@ mod test {
162
167
assert_almost_eq ( o, 0.1 ) ;
163
168
}
164
169
// Dewpoint calculation
170
+ #[ cfg( not( feature = "no_std" ) ) ]
165
171
#[ test]
166
172
fn to_dewpoint1 ( ) {
167
173
let humidity = Humidity :: from_percent ( 85.0 ) ;
168
174
let temp = Temperature :: from_celsius ( 18.0 ) ;
169
175
let dewpoint = humidity. as_dewpoint ( temp) ;
170
176
assert_almost_eq ( dewpoint. as_celsius ( ) , 15.44 ) ;
171
177
}
178
+ #[ cfg( not( feature = "no_std" ) ) ]
172
179
#[ test]
173
180
fn to_dewpoint2 ( ) {
174
181
let humidity = Humidity :: from_percent ( 40.0 ) ;
175
182
let temp = Temperature :: from_celsius ( 5.0 ) ;
176
183
let dewpoint = humidity. as_dewpoint ( temp) ;
177
184
assert_almost_eq ( dewpoint. as_celsius ( ) , -7.5 ) ;
178
185
}
186
+ #[ cfg( not( feature = "no_std" ) ) ]
179
187
#[ test]
180
188
fn to_dewpoint3 ( ) {
181
189
let humidity = Humidity :: from_percent ( 95.0 ) ;
182
190
let temp = Temperature :: from_celsius ( 30.0 ) ;
183
191
let dewpoint = humidity. as_dewpoint ( temp) ;
184
192
assert_almost_eq ( dewpoint. as_celsius ( ) , 29.11 ) ;
185
193
}
194
+ #[ cfg( not( feature = "no_std" ) ) ]
186
195
#[ test]
187
196
fn from_dewpoint1 ( ) {
188
197
let temp = Temperature :: from_celsius ( 18.0 ) ;
189
198
let dewpoint = Temperature :: from_celsius ( 15.44 ) ;
190
199
let rh = Humidity :: from_dewpoint ( dewpoint, temp) ;
191
200
assert_almost_eq ( rh. as_percent ( ) , 85.0 ) ;
192
201
}
202
+ #[ cfg( not( feature = "no_std" ) ) ]
193
203
#[ test]
194
204
fn vapour_pressure ( ) {
195
205
let humidity = Humidity :: from_percent ( 60.0 ) ;
196
206
let temp = Temperature :: from_celsius ( 25.0 ) ;
197
207
let vp = humidity. as_vapor_pressure ( temp) ;
198
208
assert_almost_eq ( vp. as_hectopascals ( ) , 19.011 ) ;
199
209
}
210
+ #[ cfg( not( feature = "no_std" ) ) ]
200
211
#[ test]
201
212
// also tests as_vapor_pressure() on the fly
202
213
fn absolute_humidity ( ) {
@@ -205,6 +216,7 @@ mod test {
205
216
let density = humidity. as_absolute_humidity ( temp) ;
206
217
assert_almost_eq ( density. as_kilograms_per_cubic_meter ( ) , 0.0138166 ) ;
207
218
}
219
+ #[ cfg( not( feature = "no_std" ) ) ]
208
220
#[ test]
209
221
// round-trip test
210
222
fn from_dewpoint2 ( ) {
0 commit comments