summary refs log tree commit diff
path: root/src/libstd/num/f64.rs
diff options
context:
space:
mode:
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-01-18 08:53:00 +1100
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-01-18 09:12:53 +1100
commit472dfe74b32bfa855b70bf8ec59beddbd0514be1 (patch)
tree15c18502fdbf22fdf3a80bda2a8968aaa39ada5c /src/libstd/num/f64.rs
parent80a3f453db387d02dcb596745731031e7a8c9048 (diff)
downloadrust-472dfe74b32bfa855b70bf8ec59beddbd0514be1.tar.gz
rust-472dfe74b32bfa855b70bf8ec59beddbd0514be1.zip
Simplify std::num::Primitive trait definition
This removes the `Primitive::{bits, bytes, is_signed}` methods and removes the operator trait constraints, for the reasons outlined below:

- The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES` statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should probably be deprecated in the future in favor of using the `std::mem::size_of` function (see #11621).

- `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for #8888.

- The operator trait constraints are already covered by the `Num` trait.
Diffstat (limited to 'src/libstd/num/f64.rs')
-rw-r--r--src/libstd/num/f64.rs18
1 files changed, 1 insertions, 17 deletions
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index fe51cb07646..bdfb42b4b88 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -556,16 +556,7 @@ impl Bounded for f64 {
     fn max_value() -> f64 { 1.7976931348623157e+308 }
 }
 
-impl Primitive for f64 {
-    #[inline]
-    fn bits(_: Option<f64>) -> uint { 64 }
-
-    #[inline]
-    fn bytes(_: Option<f64>) -> uint { Primitive::bits(Some(0f64)) / 8 }
-
-    #[inline]
-    fn is_signed(_: Option<f64>) -> bool { true }
-}
+impl Primitive for f64 {}
 
 impl Float for f64 {
     #[inline]
@@ -1179,13 +1170,6 @@ mod tests {
     }
 
     #[test]
-    fn test_primitive() {
-        let none: Option<f64> = None;
-        assert_eq!(Primitive::bits(none), mem::size_of::<f64>() * 8);
-        assert_eq!(Primitive::bytes(none), mem::size_of::<f64>());
-    }
-
-    #[test]
     fn test_is_normal() {
         let nan: f64 = Float::nan();
         let inf: f64 = Float::infinity();