Skip to content

Commit

Permalink
fix type errors due to libm crate not being generic
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz-meier authored and sevenautumns committed Sep 18, 2024
1 parent f984b96 commit 843ea1b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ features = ["usize", "u32", "u64", "isize", "i32", "i64", "bigint", "biguint", "
maintenance = { status = "actively-developed" }

[workspace]
members = [
"tests/feature_check",
"uom-macros",
"tests/edition_check",
]
members = ["tests/feature_check", "uom-macros", "tests/edition_check"]

[dependencies]
num-traits = { version = "0.2", default-features = false }
num-rational = { version = "0.4", optional = true, default-features = false }
num-bigint = { version = "0.4", optional = true, default-features = false, features = ["std"] }
num-complex = { version = "0.4", optional = true, default-features = false, features = ["std"] }
num-bigint = { version = "0.4", optional = true, default-features = false, features = [
"std",
] }
num-complex = { version = "0.4", optional = true, default-features = false, features = [
"std",
] }
serde = { version = "1.0", optional = true, default-features = false }
typenum = "1.13"

[dev-dependencies]
approx = "0.5"
libm = "0.2"
libm = { git = "https://github.com/moritz-meier/libm.git", branch = "feature/add-generic-helper" }
quickcheck = "1.0"
serde_json = "1.0"
static_assertions = "1.1"
Expand Down Expand Up @@ -83,7 +83,7 @@ rational-support = ["num-rational"]
bigint-support = ["num-bigint", "num-rational/num-bigint-std"]
complex-support = ["num-complex"]
# enable sin/cos for no_std builds, via libm
libm = [ "num-traits/libm" ]
libm = ["num-traits/libm"]

[[example]]
name = "base"
Expand Down
2 changes: 1 addition & 1 deletion src/si/angle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ mod tests {
#[allow(trivial_casts)]
fn atan2(y: V, x: V) -> bool {
let desired_value = if cfg!(feature = "libm"){
libm::atan2f(y, x)
libm::Libm::<V>::atan2(y, x)
} else {
y.atan2(x)
};
Expand Down
28 changes: 14 additions & 14 deletions src/si/ratio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ mod tests {
quickcheck! {
fn acos(x: V) -> bool {
let desired_value = if cfg!(feature = "libm") {
libm::acosf(x)
libm::Libm::<V>::acos(x)
} else {
x.acos()
};
Expand All @@ -243,7 +243,7 @@ mod tests {

fn acosh(x: V) -> bool {
let desired_value = if cfg!(feature = "libm") {
libm::acoshf(x)
libm::Libm::<V>::acosh(x)
} else {
x.acosh()
};
Expand All @@ -252,7 +252,7 @@ mod tests {

fn asin(x: V) -> bool {
let desired_value = if cfg!(feature = "libm") {
libm::asinf(x)
libm::Libm::<V>::asin(x)
} else {
x.asin()
};
Expand All @@ -261,7 +261,7 @@ mod tests {

fn asinh(x: V) -> bool {
let desired_value = if cfg!(feature = "libm") {
libm::asinhf(x)
libm::Libm::<V>::asinh(x)
} else {
x.asinh()
};
Expand All @@ -270,7 +270,7 @@ mod tests {

fn atan(x: V) -> bool {
let desired_value = if cfg!(feature = "libm") {
libm::atanf(x)
libm::Libm::<V>::atan(x)
} else {
x.atan()
};
Expand All @@ -279,7 +279,7 @@ mod tests {

fn atanh(x: V) -> bool {
let desired_value = if cfg!(feature = "libm") {
libm::atanhf(x)
libm::Libm::<V>::atanh(x)
} else {
x.atanh()
};
Expand All @@ -288,7 +288,7 @@ mod tests {

fn exp(x: V) -> bool {
let desired_value = if cfg!(feature = "libm"){
libm::expf(x)
libm::Libm::<V>::exp(x)
} else {
x.exp()
};
Expand All @@ -297,7 +297,7 @@ mod tests {

fn exp2(x: V) -> bool {
let desired_value = if cfg!(feature = "libm"){
libm::exp2f(x)
libm::Libm::<V>::exp2(x)
} else {
x.exp2()
};
Expand All @@ -306,7 +306,7 @@ mod tests {

fn ln(x: V) -> bool {
let desired_value = if cfg!(feature = "libm"){
libm::logf(x)
libm::Libm::<V>::log(x)
} else {
x.ln()
};
Expand All @@ -315,7 +315,7 @@ mod tests {

fn log(x: V, y: V) -> bool {
let desired_value = if cfg!(feature = "libm"){
libm::logf(x) / libm::logf(y)
libm::Libm::<V>::log(x) / libm::Libm::<V>::log(y)
} else {
x.log(y)
};
Expand All @@ -324,7 +324,7 @@ mod tests {

fn log2(x: V) -> bool {
let desired_value = if cfg!(feature = "libm"){
libm::log2f(x)
libm::Libm::<V>::log2(x)
} else {
x.log2()
};
Expand All @@ -333,7 +333,7 @@ mod tests {

fn log10(x: V) -> bool {
let desired_value = if cfg!(feature = "libm"){
libm::log10f(x)
libm::Libm::<V>::log10(x)
} else {
x.log10()
};
Expand All @@ -342,7 +342,7 @@ mod tests {

fn exp_m1(x: V) -> bool {
let desired_value = if cfg!(feature = "libm"){
libm::expm1f(x)
libm::Libm::<V>::expm1(x)
} else {
x.exp_m1()
};
Expand All @@ -351,7 +351,7 @@ mod tests {

fn ln_1p(x: V) -> bool {
let desired_value = if cfg!(feature = "libm"){
libm::log1pf(x)
libm::Libm::<V>::log1p(x)
} else {
x.ln_1p()
};
Expand Down
2 changes: 1 addition & 1 deletion src/tests/quantity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ mod float {
#[allow(trivial_casts)]
fn hypot_same(l: V, r: V) -> bool {
let desired_value = if cfg!(feature="libm") && ! cfg!(feature="std") {
libm::hypotf(l, r)
libm::Libm::<V>::hypot(l, r)
} else {
l.hypot(r)
};
Expand Down
2 changes: 1 addition & 1 deletion src/tests/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ mod float {
#[allow(trivial_casts)]
fn hypot(l: A<V>, r: A<V>) -> bool {
let desired_value = if cfg!(feature="libm"){
libm::hypotf(*l, *r)
libm::Libm::<V>::hypot(*l, *r)
} else {
l.hypot(*r)
};
Expand Down

0 comments on commit 843ea1b

Please sign in to comment.