11//! Types and constants for handling humidity.
22
33use super :: measurement:: * ;
4+ #[ cfg( not( feature = "no_std" ) ) ]
45use density:: Density ;
6+ #[ cfg( not( feature = "no_std" ) ) ]
57use pressure:: Pressure ;
8+ #[ cfg( not( feature = "no_std" ) ) ]
69use temperature:: Temperature ;
710
811/// The `Humidity` struct can be used to deal with relative humidity
@@ -32,7 +35,9 @@ use temperature::Temperature;
3235///
3336/// let humidity = Humidity::from_percent(85.0);
3437/// let temp = Temperature::from_celsius(18.0);
38+ /// #[cfg(not(feature="no_std"))]
3539/// let dewpoint = humidity.as_dewpoint(temp);
40+ /// #[cfg(not(feature="no_std"))]
3641/// println!("At {} humidity, air at {} has a dewpoint of {}", humidity, temp, dewpoint);
3742///
3843/// ```
@@ -162,41 +167,47 @@ mod test {
162167 assert_almost_eq ( o, 0.1 ) ;
163168 }
164169 // Dewpoint calculation
170+ #[ cfg( not( feature = "no_std" ) ) ]
165171 #[ test]
166172 fn to_dewpoint1 ( ) {
167173 let humidity = Humidity :: from_percent ( 85.0 ) ;
168174 let temp = Temperature :: from_celsius ( 18.0 ) ;
169175 let dewpoint = humidity. as_dewpoint ( temp) ;
170176 assert_almost_eq ( dewpoint. as_celsius ( ) , 15.44 ) ;
171177 }
178+ #[ cfg( not( feature = "no_std" ) ) ]
172179 #[ test]
173180 fn to_dewpoint2 ( ) {
174181 let humidity = Humidity :: from_percent ( 40.0 ) ;
175182 let temp = Temperature :: from_celsius ( 5.0 ) ;
176183 let dewpoint = humidity. as_dewpoint ( temp) ;
177184 assert_almost_eq ( dewpoint. as_celsius ( ) , -7.5 ) ;
178185 }
186+ #[ cfg( not( feature = "no_std" ) ) ]
179187 #[ test]
180188 fn to_dewpoint3 ( ) {
181189 let humidity = Humidity :: from_percent ( 95.0 ) ;
182190 let temp = Temperature :: from_celsius ( 30.0 ) ;
183191 let dewpoint = humidity. as_dewpoint ( temp) ;
184192 assert_almost_eq ( dewpoint. as_celsius ( ) , 29.11 ) ;
185193 }
194+ #[ cfg( not( feature = "no_std" ) ) ]
186195 #[ test]
187196 fn from_dewpoint1 ( ) {
188197 let temp = Temperature :: from_celsius ( 18.0 ) ;
189198 let dewpoint = Temperature :: from_celsius ( 15.44 ) ;
190199 let rh = Humidity :: from_dewpoint ( dewpoint, temp) ;
191200 assert_almost_eq ( rh. as_percent ( ) , 85.0 ) ;
192201 }
202+ #[ cfg( not( feature = "no_std" ) ) ]
193203 #[ test]
194204 fn vapour_pressure ( ) {
195205 let humidity = Humidity :: from_percent ( 60.0 ) ;
196206 let temp = Temperature :: from_celsius ( 25.0 ) ;
197207 let vp = humidity. as_vapor_pressure ( temp) ;
198208 assert_almost_eq ( vp. as_hectopascals ( ) , 19.011 ) ;
199209 }
210+ #[ cfg( not( feature = "no_std" ) ) ]
200211 #[ test]
201212 // also tests as_vapor_pressure() on the fly
202213 fn absolute_humidity ( ) {
@@ -205,6 +216,7 @@ mod test {
205216 let density = humidity. as_absolute_humidity ( temp) ;
206217 assert_almost_eq ( density. as_kilograms_per_cubic_meter ( ) , 0.0138166 ) ;
207218 }
219+ #[ cfg( not( feature = "no_std" ) ) ]
208220 #[ test]
209221 // round-trip test
210222 fn from_dewpoint2 ( ) {
0 commit comments