From 60f8a7f91c11c2be0bb980c0e72c8ed1fa4c0e36 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 29 Mar 2021 11:36:15 +0800 Subject: [PATCH] Remove Float trait. --- src/ast.rs | 3 --- src/dynamic.rs | 2 +- src/fn_builtin.rs | 4 ---- src/packages/arithmetic.rs | 4 ---- src/packages/math_basic.rs | 4 ---- src/packages/string_basic.rs | 6 ------ 6 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index 02f30e1f..86d0e017 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -1480,9 +1480,6 @@ impl fmt::Debug for FloatWrapper { impl fmt::Display for FloatWrapper { #[inline(always)] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - #[cfg(feature = "no_std")] - use num_traits::Float; - let abs = self.0.abs(); if abs > 10000000000000.0 || abs < 0.0000000000001 { write!(f, "{:e}", self.0) diff --git a/src/dynamic.rs b/src/dynamic.rs index f32b68b7..477075af 100644 --- a/src/dynamic.rs +++ b/src/dynamic.rs @@ -8,7 +8,7 @@ use crate::stdlib::{ fmt, hash::{Hash, Hasher}, ops::{Deref, DerefMut}, - string::String, + string::{String, ToString}, }; use crate::{FnPtr, ImmutableString, INT}; diff --git a/src/fn_builtin.rs b/src/fn_builtin.rs index 4b79cc62..8e00463c 100644 --- a/src/fn_builtin.rs +++ b/src/fn_builtin.rs @@ -11,10 +11,6 @@ use crate::FLOAT; #[cfg(feature = "decimal")] use rust_decimal::Decimal; -#[cfg(feature = "no_std")] -#[cfg(not(feature = "no_float"))] -use num_traits::float::Float; - /// Is the type a numeric type? #[inline(always)] fn is_numeric(type_id: TypeId) -> bool { diff --git a/src/packages/arithmetic.rs b/src/packages/arithmetic.rs index 1346a5b3..07d838b9 100644 --- a/src/packages/arithmetic.rs +++ b/src/packages/arithmetic.rs @@ -7,10 +7,6 @@ use crate::{def_package, EvalAltResult, Position, INT}; #[cfg(not(feature = "no_float"))] use crate::FLOAT; -#[cfg(feature = "no_std")] -#[cfg(not(feature = "no_float"))] -use num_traits::float::Float; - #[inline(always)] pub fn make_err(msg: impl Into) -> Box { EvalAltResult::ErrorArithmetic(msg.into(), Position::NONE).into() diff --git a/src/packages/math_basic.rs b/src/packages/math_basic.rs index 2ed73a62..e229e282 100644 --- a/src/packages/math_basic.rs +++ b/src/packages/math_basic.rs @@ -9,10 +9,6 @@ use crate::FLOAT; #[cfg(not(feature = "no_float"))] use crate::result::EvalAltResult; -#[cfg(feature = "no_std")] -#[cfg(not(feature = "no_float"))] -use num_traits::float::Float; - #[cfg(not(feature = "no_float"))] use crate::stdlib::format; diff --git a/src/packages/string_basic.rs b/src/packages/string_basic.rs index 3861a0a2..71341c44 100644 --- a/src/packages/string_basic.rs +++ b/src/packages/string_basic.rs @@ -57,9 +57,6 @@ mod print_debug_functions { pub mod float_functions { #[rhai_fn(name = "print", name = "to_string")] pub fn print_f64(number: f64) -> ImmutableString { - #[cfg(feature = "no_std")] - use num_traits::Float; - let abs = number.abs(); if abs > 10000000000000.0 || abs < 0.0000000000001 { format!("{:e}", number).into() @@ -69,9 +66,6 @@ mod print_debug_functions { } #[rhai_fn(name = "print", name = "to_string")] pub fn print_f32(number: f32) -> ImmutableString { - #[cfg(feature = "no_std")] - use num_traits::Float; - let abs = number.abs(); if abs > 10000000000000.0 || abs < 0.0000000000001 { format!("{:e}", number).into()