From 843ea1b97f6c1eab82da885810c0f1bc9d593142 Mon Sep 17 00:00:00 2001 From: Moritz Meier Date: Tue, 10 Jan 2023 19:18:23 +0100 Subject: [PATCH] fix type errors due to libm crate not being generic --- Cargo.toml | 18 +++++++++--------- src/si/angle.rs | 2 +- src/si/ratio.rs | 28 ++++++++++++++-------------- src/tests/quantity.rs | 2 +- src/tests/system.rs | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 87d425b6..25dd0de8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" @@ -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" diff --git a/src/si/angle.rs b/src/si/angle.rs index adf150e2..ed337995 100644 --- a/src/si/angle.rs +++ b/src/si/angle.rs @@ -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::::atan2(y, x) } else { y.atan2(x) }; diff --git a/src/si/ratio.rs b/src/si/ratio.rs index 3206dade..c87eb424 100644 --- a/src/si/ratio.rs +++ b/src/si/ratio.rs @@ -234,7 +234,7 @@ mod tests { quickcheck! { fn acos(x: V) -> bool { let desired_value = if cfg!(feature = "libm") { - libm::acosf(x) + libm::Libm::::acos(x) } else { x.acos() }; @@ -243,7 +243,7 @@ mod tests { fn acosh(x: V) -> bool { let desired_value = if cfg!(feature = "libm") { - libm::acoshf(x) + libm::Libm::::acosh(x) } else { x.acosh() }; @@ -252,7 +252,7 @@ mod tests { fn asin(x: V) -> bool { let desired_value = if cfg!(feature = "libm") { - libm::asinf(x) + libm::Libm::::asin(x) } else { x.asin() }; @@ -261,7 +261,7 @@ mod tests { fn asinh(x: V) -> bool { let desired_value = if cfg!(feature = "libm") { - libm::asinhf(x) + libm::Libm::::asinh(x) } else { x.asinh() }; @@ -270,7 +270,7 @@ mod tests { fn atan(x: V) -> bool { let desired_value = if cfg!(feature = "libm") { - libm::atanf(x) + libm::Libm::::atan(x) } else { x.atan() }; @@ -279,7 +279,7 @@ mod tests { fn atanh(x: V) -> bool { let desired_value = if cfg!(feature = "libm") { - libm::atanhf(x) + libm::Libm::::atanh(x) } else { x.atanh() }; @@ -288,7 +288,7 @@ mod tests { fn exp(x: V) -> bool { let desired_value = if cfg!(feature = "libm"){ - libm::expf(x) + libm::Libm::::exp(x) } else { x.exp() }; @@ -297,7 +297,7 @@ mod tests { fn exp2(x: V) -> bool { let desired_value = if cfg!(feature = "libm"){ - libm::exp2f(x) + libm::Libm::::exp2(x) } else { x.exp2() }; @@ -306,7 +306,7 @@ mod tests { fn ln(x: V) -> bool { let desired_value = if cfg!(feature = "libm"){ - libm::logf(x) + libm::Libm::::log(x) } else { x.ln() }; @@ -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::::log(x) / libm::Libm::::log(y) } else { x.log(y) }; @@ -324,7 +324,7 @@ mod tests { fn log2(x: V) -> bool { let desired_value = if cfg!(feature = "libm"){ - libm::log2f(x) + libm::Libm::::log2(x) } else { x.log2() }; @@ -333,7 +333,7 @@ mod tests { fn log10(x: V) -> bool { let desired_value = if cfg!(feature = "libm"){ - libm::log10f(x) + libm::Libm::::log10(x) } else { x.log10() }; @@ -342,7 +342,7 @@ mod tests { fn exp_m1(x: V) -> bool { let desired_value = if cfg!(feature = "libm"){ - libm::expm1f(x) + libm::Libm::::expm1(x) } else { x.exp_m1() }; @@ -351,7 +351,7 @@ mod tests { fn ln_1p(x: V) -> bool { let desired_value = if cfg!(feature = "libm"){ - libm::log1pf(x) + libm::Libm::::log1p(x) } else { x.ln_1p() }; diff --git a/src/tests/quantity.rs b/src/tests/quantity.rs index b2cdf9e7..27859c6a 100644 --- a/src/tests/quantity.rs +++ b/src/tests/quantity.rs @@ -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::::hypot(l, r) } else { l.hypot(r) }; diff --git a/src/tests/system.rs b/src/tests/system.rs index bd98a2ee..e227cda5 100644 --- a/src/tests/system.rs +++ b/src/tests/system.rs @@ -300,7 +300,7 @@ mod float { #[allow(trivial_casts)] fn hypot(l: A, r: A) -> bool { let desired_value = if cfg!(feature="libm"){ - libm::hypotf(*l, *r) + libm::Libm::::hypot(*l, *r) } else { l.hypot(*r) };