diff options
| author | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2013-04-26 19:56:11 +1000 |
|---|---|---|
| committer | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2013-04-26 19:56:11 +1000 |
| commit | 6efbbf2e1481c3f42d7bd1cd7008fdc54939d9d3 (patch) | |
| tree | c229ca5c81f0a066d2ee05ada4f49aee3bfce41c | |
| parent | faaf3bf1495a8d76e822981544de2b346346d91d (diff) | |
| download | rust-6efbbf2e1481c3f42d7bd1cd7008fdc54939d9d3.tar.gz rust-6efbbf2e1481c3f42d7bd1cd7008fdc54939d9d3.zip | |
Combine PrimitiveInt, Int, and Uint traits into one single trait
Having three traits for primitive ints/uints seemed rather excessive. If users wish to specify between them they can simply combine Int with either the Signed and Unsigned traits. For example: fn foo<T: Int + Signed>() { … }
| -rw-r--r-- | src/libcore/core.rc | 3 | ||||
| -rw-r--r-- | src/libcore/num/int-template.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/num.rs | 22 | ||||
| -rw-r--r-- | src/libcore/num/uint-template.rs | 4 | ||||
| -rw-r--r-- | src/libcore/prelude.rs | 3 |
5 files changed, 8 insertions, 26 deletions
diff --git a/src/libcore/core.rc b/src/libcore/core.rc index b7d657669fe..47f83103b79 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -107,8 +107,7 @@ pub use num::{Num, NumCast}; pub use num::{Signed, Unsigned, Integer}; pub use num::{Round, Fractional, Real, RealExt}; pub use num::{Bitwise, BitCount, Bounded}; -pub use num::{Primitive, PrimitiveInt}; -pub use num::{Int, Uint, Float}; +pub use num::{Primitive, Int, Float}; pub use ptr::Ptr; pub use to_str::ToStr; pub use clone::Clone; diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 11dacdd4493..0c126bd1de5 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -445,8 +445,6 @@ impl Bounded for T { fn max_value() -> T { max_value } } -impl PrimitiveInt for T {} - impl Int for T {} // String conversion functions and impl str -> num diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index cec5fe8cd28..f1a77a4ed59 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -217,23 +217,11 @@ pub trait Primitive: Num /// /// A collection of traits relevant to primitive signed and unsigned integers /// -pub trait PrimitiveInt: Integer - + Primitive - + Bounded - + Bitwise - + BitCount {} - -/// -/// Specialisation of `PrimitiveInt` for unsigned integers -/// -pub trait Uint: PrimitiveInt - + Unsigned {} - -/// -/// Specialisation of `PrimitiveInt` for signed integers -/// -pub trait Int: PrimitiveInt - + Signed {} +pub trait Int: Integer + + Primitive + + Bounded + + Bitwise + + BitCount {} /// /// Primitive floating point numbers. This trait should only be implemented diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 2e6c7e28b18..d84f4a99d53 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -277,9 +277,7 @@ impl Bounded for T { fn max_value() -> T { max_value } } -impl PrimitiveInt for T {} - -impl Uint for T {} +impl Int for T {} // String conversion functions and impl str -> num diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index 1ab6f8d4441..2711399c483 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -41,8 +41,7 @@ pub use num::{Num, NumCast}; pub use num::{Signed, Unsigned, Integer}; pub use num::{Round, Fractional, Real, RealExt}; pub use num::{Bitwise, BitCount, Bounded}; -pub use num::{Primitive, PrimitiveInt}; -pub use num::{Int, Uint, Float}; +pub use num::{Primitive, Int, Float}; pub use path::GenericPath; pub use path::Path; pub use path::PosixPath; |
