about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2015-01-05 18:30:55 +1100
committerHuon Wilson <dbau.pp+github@gmail.com>2015-01-06 23:21:01 +1100
commitcd4ed38404384bdb13500f1d2e782d32ece2b239 (patch)
treed0ae795a9b726c0d795c006a430127556e5a1de8 /src/libcore
parentcfb2e2acd72c651f97f285a86956f3f01a461a2d (diff)
downloadrust-cd4ed38404384bdb13500f1d2e782d32ece2b239.tar.gz
rust-cd4ed38404384bdb13500f1d2e782d32ece2b239.zip
Deprecate the constant-returning functions in Float.
These are replaced by the equivalent constants in `std::f32` and
`std::f64` respectively.

[breaking-change]
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/num/f32.rs10
-rw-r--r--src/libcore/num/f64.rs10
-rw-r--r--src/libcore/num/mod.rs16
3 files changed, 33 insertions, 3 deletions
diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs
index aab28ae9c47..d2334943b3d 100644
--- a/src/libcore/num/f32.rs
+++ b/src/libcore/num/f32.rs
@@ -177,33 +177,43 @@ impl Float for f32 {
     }
 
     #[inline]
+    #[deprecated]
     fn mantissa_digits(_: Option<f32>) -> uint { MANTISSA_DIGITS }
 
     #[inline]
+    #[deprecated]
     fn digits(_: Option<f32>) -> uint { DIGITS }
 
     #[inline]
+    #[deprecated]
     fn epsilon() -> f32 { EPSILON }
 
     #[inline]
+    #[deprecated]
     fn min_exp(_: Option<f32>) -> int { MIN_EXP }
 
     #[inline]
+    #[deprecated]
     fn max_exp(_: Option<f32>) -> int { MAX_EXP }
 
     #[inline]
+    #[deprecated]
     fn min_10_exp(_: Option<f32>) -> int { MIN_10_EXP }
 
     #[inline]
+    #[deprecated]
     fn max_10_exp(_: Option<f32>) -> int { MAX_10_EXP }
 
     #[inline]
+    #[deprecated]
     fn min_value() -> f32 { MIN_VALUE }
 
     #[inline]
+    #[deprecated]
     fn min_pos_value(_: Option<f32>) -> f32 { MIN_POS_VALUE }
 
     #[inline]
+    #[deprecated]
     fn max_value() -> f32 { MAX_VALUE }
 
     /// Returns the mantissa, exponent and sign as integers.
diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs
index d6d9c3446e9..95cc5f22409 100644
--- a/src/libcore/num/f64.rs
+++ b/src/libcore/num/f64.rs
@@ -185,33 +185,43 @@ impl Float for f64 {
     }
 
     #[inline]
+    #[deprecated]
     fn mantissa_digits(_: Option<f64>) -> uint { MANTISSA_DIGITS }
 
     #[inline]
+    #[deprecated]
     fn digits(_: Option<f64>) -> uint { DIGITS }
 
     #[inline]
+    #[deprecated]
     fn epsilon() -> f64 { EPSILON }
 
     #[inline]
+    #[deprecated]
     fn min_exp(_: Option<f64>) -> int { MIN_EXP }
 
     #[inline]
+    #[deprecated]
     fn max_exp(_: Option<f64>) -> int { MAX_EXP }
 
     #[inline]
+    #[deprecated]
     fn min_10_exp(_: Option<f64>) -> int { MIN_10_EXP }
 
     #[inline]
+    #[deprecated]
     fn max_10_exp(_: Option<f64>) -> int { MAX_10_EXP }
 
     #[inline]
+    #[deprecated]
     fn min_value() -> f64 { MIN_VALUE }
 
     #[inline]
+    #[deprecated]
     fn min_pos_value(_: Option<f64>) -> f64 { MIN_POS_VALUE }
 
     #[inline]
+    #[deprecated]
     fn max_value() -> f64 { MAX_VALUE }
 
     /// Returns the mantissa, exponent and sign as integers.
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 87973eacc66..1f20fae2f45 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -910,12 +910,12 @@ impl_to_primitive_uint! { u32 }
 impl_to_primitive_uint! { u64 }
 
 macro_rules! impl_to_primitive_float_to_float {
-    ($SrcT:ty, $DstT:ty, $slf:expr) => (
+    ($SrcT:ident, $DstT:ident, $slf:expr) => (
         if size_of::<$SrcT>() <= size_of::<$DstT>() {
             Some($slf as $DstT)
         } else {
             let n = $slf as f64;
-            let max_value: $SrcT = Float::max_value();
+            let max_value: $SrcT = ::$SrcT::MAX_VALUE;
             if -max_value as f64 <= n && n <= max_value as f64 {
                 Some($slf as $DstT)
             } else {
@@ -926,7 +926,7 @@ macro_rules! impl_to_primitive_float_to_float {
 }
 
 macro_rules! impl_to_primitive_float {
-    ($T:ty) => (
+    ($T:ident) => (
         impl ToPrimitive for $T {
             #[inline]
             fn to_int(&self) -> Option<int> { Some(*self as int) }
@@ -1251,24 +1251,34 @@ pub trait Float
     // FIXME (#5527): These should be associated constants
 
     /// Returns the number of binary digits of mantissa that this type supports.
+    #[deprecated = "use `std::f32::MANTISSA_DIGITS` or `std::f64::MANTISSA_DIGITS` as appropriate"]
     fn mantissa_digits(unused_self: Option<Self>) -> uint;
     /// Returns the number of base-10 digits of precision that this type supports.
+    #[deprecated = "use `std::f32::DIGITS` or `std::f64::DIGITS` as appropriate"]
     fn digits(unused_self: Option<Self>) -> uint;
     /// Returns the difference between 1.0 and the smallest representable number larger than 1.0.
+    #[deprecated = "use `std::f32::EPSILON` or `std::f64::EPSILON` as appropriate"]
     fn epsilon() -> Self;
     /// Returns the minimum binary exponent that this type can represent.
+    #[deprecated = "use `std::f32::MIN_EXP` or `std::f64::MIN_EXP` as appropriate"]
     fn min_exp(unused_self: Option<Self>) -> int;
     /// Returns the maximum binary exponent that this type can represent.
+    #[deprecated = "use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` as appropriate"]
     fn max_exp(unused_self: Option<Self>) -> int;
     /// Returns the minimum base-10 exponent that this type can represent.
+    #[deprecated = "use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` as appropriate"]
     fn min_10_exp(unused_self: Option<Self>) -> int;
     /// Returns the maximum base-10 exponent that this type can represent.
+    #[deprecated = "use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` as appropriate"]
     fn max_10_exp(unused_self: Option<Self>) -> int;
     /// Returns the smallest finite value that this type can represent.
+    #[deprecated = "use `std::f32::MIN_VALUE` or `std::f64::MIN_VALUE` as appropriate"]
     fn min_value() -> Self;
     /// Returns the smallest normalized positive number that this type can represent.
+    #[deprecated = "use `std::f32::MIN_POS_VALUE` or `std::f64::MIN_POS_VALUE` as appropriate"]
     fn min_pos_value(unused_self: Option<Self>) -> Self;
     /// Returns the largest finite value that this type can represent.
+    #[deprecated = "use `std::f32::MAX_VALUE` or `std::f64::MAX_VALUE` as appropriate"]
     fn max_value() -> Self;
 
     /// Returns true if this value is NaN and false otherwise.