From a5fa8322e915e405d5f3120f7ac6d1caf6a96697 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 20 Jul 2020 20:23:35 +0800 Subject: [PATCH] Avoid pulling in std for no-std. --- Cargo.toml | 1 + src/packages/arithmetic.rs | 3 +++ src/packages/math_basic.rs | 3 +++ src/parser.rs | 1 + 4 files changed, 8 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 46c208c3..bf4e0dc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,7 @@ codegen-units = 1 [dependencies.libm] version = "0.2.1" +default_features = false optional = true [dependencies.core-error] diff --git a/src/packages/arithmetic.rs b/src/packages/arithmetic.rs index 7a548ff0..8aeb1590 100644 --- a/src/packages/arithmetic.rs +++ b/src/packages/arithmetic.rs @@ -7,6 +7,9 @@ use crate::token::Position; #[cfg(not(feature = "no_float"))] use crate::parser::FLOAT; +#[cfg(not(feature = "no_float"))] +use num_traits::*; + use num_traits::{ identities::Zero, CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl, CheckedShr, CheckedSub, diff --git a/src/packages/math_basic.rs b/src/packages/math_basic.rs index e7ce43b7..ca0bc374 100644 --- a/src/packages/math_basic.rs +++ b/src/packages/math_basic.rs @@ -6,6 +6,9 @@ use crate::token::Position; #[cfg(not(feature = "no_float"))] use crate::parser::FLOAT; +#[cfg(not(feature = "no_float"))] +use num_traits::*; + use crate::stdlib::{boxed::Box, format, i32, i64}; #[cfg(feature = "only_i32")] diff --git a/src/parser.rs b/src/parser.rs index 610bc6e2..ce0eb686 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -608,6 +608,7 @@ impl Hash for CustomExpr { #[derive(Debug, PartialEq, PartialOrd, Clone)] pub struct FloatWrapper(pub FLOAT, pub Position); +#[cfg(not(feature = "no_float"))] impl Hash for FloatWrapper { fn hash(&self, state: &mut H) { state.write(&self.0.to_le_bytes());