Remove Float trait.

This commit is contained in:
Stephen Chung 2021-03-29 11:36:15 +08:00
parent e5249cc1ae
commit 60f8a7f91c
6 changed files with 1 additions and 22 deletions

View File

@ -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)

View File

@ -8,7 +8,7 @@ use crate::stdlib::{
fmt,
hash::{Hash, Hasher},
ops::{Deref, DerefMut},
string::String,
string::{String, ToString},
};
use crate::{FnPtr, ImmutableString, INT};

View File

@ -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 {

View File

@ -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<String>) -> Box<EvalAltResult> {
EvalAltResult::ErrorArithmetic(msg.into(), Position::NONE).into()

View File

@ -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;

View File

@ -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()