Sfoglia il codice sorgente

Don't use libm at all with std

Josh Stone 5 anni fa
parent
commit
c4256bd4df
2 ha cambiato i file con 4 aggiunte e 3 eliminazioni
  1. 2 2
      src/float.rs
  2. 2 1
      src/lib.rs

+ 2 - 2
src/float.rs

@@ -7,7 +7,7 @@ use core::f64;
 
 use {Num, NumCast, ToPrimitive};
 
-#[cfg(feature = "libm")]
+#[cfg(all(not(feature = "std"), feature = "libm"))]
 use libm::{F32Ext, F64Ext};
 
 /// Generic trait for floating point numbers that works with `no_std`.
@@ -1887,7 +1887,7 @@ macro_rules! float_impl_std {
     };
 }
 
-#[cfg(feature = "libm")]
+#[cfg(all(not(feature = "std"), feature = "libm"))]
 macro_rules! float_impl_libm {
     ($T:ident $decode:ident $LibmImpl:ident) => {
         impl Float for $T {

+ 2 - 1
src/lib.rs

@@ -20,7 +20,8 @@
 #[cfg(feature = "std")]
 extern crate std;
 
-#[cfg(feature = "libm")]
+// Only `no_std` builds actually use `libm`.
+#[cfg(all(not(feature = "std"), feature = "libm"))]
 extern crate libm;
 
 use core::fmt;