Skip to content

Commit dc74f8b

Browse files
jhbruhneldruin
authored andcommitted
Replace no_std feature with std feature
1 parent 043968f commit dc74f8b

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ license = "MIT"
1515
readme = "README.md"
1616

1717
[features]
18-
no_std = [ "libm" ]
18+
std = []
1919
from_str = ["regex"]
2020

2121
[dependencies]
22-
serde = { version = "1.0", optional = true, features = ["derive"] }
22+
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }
2323
regex = { version = "1", optional = true }
24-
libm = { version = "0.2", optional = true }
24+
libm = { version = "0.2" }

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ fn main() {
8989

9090
The crate contains few features to disable or enable certain functionalities:
9191

92-
* no_std
93-
* Removes functionality that Rust std library provides
92+
* std
93+
* Enables functionality that Rust std library provides instead of using libm for some maths functions
9494
* from_str
9595
* Allows creating measurement units from string input
9696

src/angle.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,43 +47,43 @@ impl Angle {
4747
}
4848

4949
/// Calculate the cosine of this angle
50-
#[cfg(not(feature = "no_std"))]
50+
#[cfg(feature = "std")]
5151
pub fn cos(&self) -> f64 {
5252
self.radians.cos()
5353
}
5454

5555
/// Calculate the sine of this angle
56-
#[cfg(not(feature = "no_std"))]
56+
#[cfg(feature = "std")]
5757
pub fn sin(&self) -> f64 {
5858
self.radians.sin()
5959
}
6060

6161
/// Calculate the sine and cosine of this angle
62-
#[cfg(not(feature = "no_std"))]
62+
#[cfg(feature = "std")]
6363
pub fn sin_cos(&self) -> (f64, f64) {
6464
self.radians.sin_cos()
6565
}
6666

6767
/// Calculate the tangent of this angle
68-
#[cfg(not(feature = "no_std"))]
68+
#[cfg(feature = "std")]
6969
pub fn tan(&self) -> f64 {
7070
self.radians.tan()
7171
}
7272

7373
/// Calculate the arcsine of a number
74-
#[cfg(not(feature = "no_std"))]
74+
#[cfg(feature = "std")]
7575
pub fn asin(num: f64) -> Self {
7676
Angle::from_radians(num.asin())
7777
}
7878

7979
/// Calculate the arccosine of a number
80-
#[cfg(not(feature = "no_std"))]
80+
#[cfg(feature = "std")]
8181
pub fn acos(num: f64) -> Self {
8282
Angle::from_radians(num.acos())
8383
}
8484

8585
/// Calculate the arctangent of a number
86-
#[cfg(not(feature = "no_std"))]
86+
#[cfg(feature = "std")]
8787
pub fn atan(num: f64) -> Self {
8888
Angle::from_radians(num.atan())
8989
}

src/humidity.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Humidity {
6969
/// Calculates Dewpoint from humidity and air temperature using the Magnus-Tetens
7070
/// approximation, with coefficients derived by Alduchov and Eskridge (1996). The formulas assume
7171
// standard atmospheric pressure.
72-
#[cfg(not(feature = "no_std"))]
72+
#[cfg(feature = "std")]
7373
pub fn as_dewpoint(&self, temp: Temperature) -> Temperature {
7474
let humidity = self.relative_humidity / 100.0;
7575
let celsius = temp.as_celsius();
@@ -81,7 +81,7 @@ impl Humidity {
8181
/// Calculates Dewpoint from humidity and air temperature using the Magnus-Tetens
8282
/// approximation, with coefficients derived by Alduchov and Eskridge (1996). The formulas assume
8383
// standard atmospheric pressure.
84-
#[cfg(feature = "no_std")]
84+
#[cfg(not(feature = "std"))]
8585
pub fn as_dewpoint(&self, temp: Temperature) -> Temperature {
8686
let humidity = self.relative_humidity / 100.0;
8787
let celsius = temp.as_celsius();
@@ -94,7 +94,7 @@ impl Humidity {
9494
/// Calculates the actual vapour pressure in the air, based on the air temperature and humidity
9595
/// at standard atmospheric pressure (1013.25 mb), using the Buck formula (accurate to +/- 0.02%
9696
/// between 0 deg C and 50 deg C)
97-
#[cfg(not(feature = "no_std"))]
97+
#[cfg(feature = "std")]
9898
pub fn as_vapor_pressure(&self, temp: Temperature) -> Pressure {
9999
let temp = temp.as_celsius();
100100
let saturation_vapor_pressure =
@@ -105,7 +105,7 @@ impl Humidity {
105105
/// Calculates the actual vapour pressure in the air, based on the air temperature and humidity
106106
/// at standard atmospheric pressure (1013.25 mb), using the Buck formula (accurate to +/- 0.02%
107107
/// between 0 deg C and 50 deg C)
108-
#[cfg(feature = "no_std")]
108+
#[cfg(not(feature = "std"))]
109109
pub fn as_vapor_pressure(&self, temp: Temperature) -> Pressure {
110110
let temp = temp.as_celsius();
111111
let saturation_vapor_pressure =
@@ -125,7 +125,7 @@ impl Humidity {
125125
/// Calculates humidity from dewpoint and air temperature using the Magnus-Tetens
126126
/// Approximation, with coefficients derived by Alduchov and Eskridge (1996). The formulas assume
127127
// standard atmospheric pressure.
128-
#[cfg(not(feature = "no_std"))]
128+
#[cfg(feature = "std")]
129129
pub fn from_dewpoint(dewpoint: Temperature, temp: Temperature) -> Humidity {
130130
let dewpoint = dewpoint.as_celsius();
131131
let temp = temp.as_celsius();
@@ -138,7 +138,7 @@ impl Humidity {
138138
/// Calculates humidity from dewpoint and air temperature using the Magnus-Tetens
139139
/// Approximation, with coefficients derived by Alduchov and Eskridge (1996). The formulas assume
140140
// standard atmospheric pressure.
141-
#[cfg(feature = "no_std")]
141+
#[cfg(not(feature = "std"))]
142142
pub fn from_dewpoint(dewpoint: Temperature, temp: Temperature) -> Humidity {
143143
let dewpoint = dewpoint.as_celsius();
144144
let temp = temp.as_celsius();

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
//! by an Area to get a Pressure.
88
99
#![deny(warnings, missing_docs)]
10-
#![cfg_attr(feature = "no_std", no_std)]
10+
#![cfg_attr(not(feature = "std"), no_std)]
1111

12-
#[cfg(feature = "no_std")]
12+
#[cfg(not(feature = "std"))]
1313
use core as std;
14-
#[cfg(feature = "no_std")]
14+
#[cfg(not(feature = "std"))]
1515
use core::time;
1616

17-
#[cfg(not(feature = "no_std"))]
17+
#[cfg(feature = "std")]
1818
use std::time;
1919

2020
#[cfg(feature = "serde")]

0 commit comments

Comments
 (0)