From efad5329b45b2785dae8523f1498d9a2a49c47f8 Mon Sep 17 00:00:00 2001 From: Vinzent Steinberg Date: Wed, 7 Feb 2018 12:32:53 +0100 Subject: [PATCH] Rename CoreFloat to FloatCore --- src/cast.rs | 4 ++-- src/float.rs | 30 +++++++++++++++--------------- src/lib.rs | 2 +- src/sign.rs | 6 +++--- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/cast.rs b/src/cast.rs index 07ead82..3d7d0a6 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -4,7 +4,7 @@ use core::num::Wrapping; use identities::Zero; use bounds::Bounded; -use float::CoreFloat; +use float::FloatCore; /// A generic trait for converting a value to a number. pub trait ToPrimitive { @@ -229,7 +229,7 @@ macro_rules! impl_to_primitive_float_to_float { // NaN and +-inf are cast as they are. let n = $slf as f64; let max_value: $DstT = ::core::$DstT::MAX; - if !CoreFloat::is_finite(n) || (-max_value as f64 <= n && n <= max_value as f64) + if !FloatCore::is_finite(n) || (-max_value as f64 <= n && n <= max_value as f64) { Some($slf as $DstT) } else { diff --git a/src/float.rs b/src/float.rs index 669fb4c..7843285 100644 --- a/src/float.rs +++ b/src/float.rs @@ -13,7 +13,7 @@ use NumCast; /// Generic trait for floating point numbers that works with `no_std`. /// /// This trait implements a subset of the `Float` trait. -pub trait CoreFloat: Num + Neg + PartialOrd + Copy { +pub trait FloatCore: Num + Neg + PartialOrd + Copy { /// Returns positive infinity. #[inline] fn infinity() -> Self; @@ -56,8 +56,8 @@ pub trait CoreFloat: Num + Neg + PartialOrd + Copy { #[inline] fn classify(self) -> FpCategory; - /// Computes the absolute value of `self`. Returns `CoreFloat::nan()` if the - /// number is `CoreFloat::nan()`. + /// Computes the absolute value of `self`. Returns `FloatCore::nan()` if the + /// number is `FloatCore::nan()`. #[inline] fn abs(self) -> Self { if self.is_sign_positive() { @@ -71,9 +71,9 @@ pub trait CoreFloat: Num + Neg + PartialOrd + Copy { /// Returns a number that represents the sign of `self`. /// - /// - `1.0` if the number is positive, `+0.0` or `CoreFloat::infinity()` - /// - `-1.0` if the number is negative, `-0.0` or `CoreFloat::neg_infinity()` - /// - `CoreFloat::nan()` if the number is `CoreFloat::nan()` + /// - `1.0` if the number is positive, `+0.0` or `FloatCore::infinity()` + /// - `-1.0` if the number is negative, `-0.0` or `FloatCore::neg_infinity()` + /// - `FloatCore::nan()` if the number is `FloatCore::nan()` #[inline] fn signum(self) -> Self { if self.is_sign_positive() { @@ -86,14 +86,14 @@ pub trait CoreFloat: Num + Neg + PartialOrd + Copy { } /// Returns `true` if `self` is positive, including `+0.0` and - /// `CoreFloat::infinity()`. + /// `FloatCore::infinity()`. #[inline] fn is_sign_positive(self) -> bool { self > Self::zero() || (Self::one() / self) == Self::infinity() } /// Returns `true` if `self` is negative, including `-0.0` and - /// `CoreFloat::neg_infinity()`. + /// `FloatCore::neg_infinity()`. #[inline] fn is_sign_negative(self) -> bool { self < Self::zero() || (Self::one() / self) == Self::neg_infinity() @@ -155,7 +155,7 @@ pub trait CoreFloat: Num + Neg + PartialOrd + Copy { fn to_radians(self) -> Self; } -impl CoreFloat for f32 { +impl FloatCore for f32 { fn infinity() -> Self { ::core::f32::INFINITY } @@ -186,7 +186,7 @@ impl CoreFloat for f32 { } } -impl CoreFloat for f64 { +impl FloatCore for f64 { fn infinity() -> Self { ::core::f64::INFINITY } @@ -1549,15 +1549,15 @@ mod tests { #[test] fn convert_deg_rad() { - use CoreFloat; + use FloatCore; for &(deg, rad) in &DEG_RAD_PAIRS { - assert!((CoreFloat::to_degrees(rad) - deg).abs() < 1e-6); - assert!((CoreFloat::to_radians(deg) - rad).abs() < 1e-6); + assert!((FloatCore::to_degrees(rad) - deg).abs() < 1e-6); + assert!((FloatCore::to_radians(deg) - rad).abs() < 1e-6); let (deg, rad) = (deg as f32, rad as f32); - assert!((CoreFloat::to_degrees(rad) - deg).abs() < 1e-6); - assert!((CoreFloat::to_radians(deg) - rad).abs() < 1e-6); + assert!((FloatCore::to_degrees(rad) - deg).abs() < 1e-6); + assert!((FloatCore::to_radians(deg) - rad).abs() < 1e-6); } } diff --git a/src/lib.rs b/src/lib.rs index 39875de..a48bc6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ use core::fmt; pub use bounds::Bounded; #[cfg(feature = "std")] pub use float::Float; -pub use float::{CoreFloat, FloatConst}; +pub use float::{FloatCore, FloatConst}; // pub use real::Real; // NOTE: Don't do this, it breaks `use num_traits::*;`. pub use identities::{Zero, One, zero, one}; pub use ops::checked::{CheckedAdd, CheckedSub, CheckedMul, CheckedDiv, CheckedShl, CheckedShr}; diff --git a/src/sign.rs b/src/sign.rs index 8d8f25b..345dcba 100644 --- a/src/sign.rs +++ b/src/sign.rs @@ -4,7 +4,7 @@ use core::num::Wrapping; use Num; #[cfg(not(feature = "std"))] -use float::CoreFloat; +use float::FloatCore; /// Useful functions for signed numbers (i.e. numbers that can be negative). pub trait Signed: Sized + Num + Neg { @@ -124,8 +124,8 @@ macro_rules! signed_float_impl { /// - `NAN` if the number is NaN #[inline] fn signum(&self) -> $t { - use CoreFloat; - CoreFloat::signum(*self) + use FloatCore; + FloatCore::signum(*self) } /// Returns `true` if the number is positive, including `+0.0` and `INFINITY`