diff options
| author | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-01-18 08:53:00 +1100 |
|---|---|---|
| committer | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-01-18 09:12:53 +1100 |
| commit | 472dfe74b32bfa855b70bf8ec59beddbd0514be1 (patch) | |
| tree | 15c18502fdbf22fdf3a80bda2a8968aaa39ada5c /src/libstd/num/int_macros.rs | |
| parent | 80a3f453db387d02dcb596745731031e7a8c9048 (diff) | |
| download | rust-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/int_macros.rs')
| -rw-r--r-- | src/libstd/num/int_macros.rs | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index add0991f7af..80bc24e2d62 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -361,16 +361,7 @@ impl Bounded for $T { impl Int for $T {} -impl Primitive for $T { - #[inline] - fn bits(_: Option<$T>) -> uint { bits } - - #[inline] - fn bytes(_: Option<$T>) -> uint { bits / 8 } - - #[inline] - fn is_signed(_: Option<$T>) -> bool { true } -} +impl Primitive for $T {} // String conversion functions and impl str -> num @@ -640,13 +631,6 @@ mod tests { } #[test] - fn test_primitive() { - let none: Option<$T> = None; - assert_eq!(Primitive::bits(none), mem::size_of::<$T>() * 8); - assert_eq!(Primitive::bytes(none), mem::size_of::<$T>()); - } - - #[test] fn test_from_str() { assert_eq!(from_str::<$T>("0"), Some(0 as $T)); assert_eq!(from_str::<$T>("3"), Some(3 as $T)); |
