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>() { … }
This commit is contained in:
Brendan Zabarauskas 2013-04-26 19:56:11 +10:00
parent faaf3bf149
commit 6efbbf2e14
5 changed files with 8 additions and 26 deletions

View File

@ -107,8 +107,7 @@ pub use num::{Num, NumCast};
pub use num::{Signed, Unsigned, Integer}; pub use num::{Signed, Unsigned, Integer};
pub use num::{Round, Fractional, Real, RealExt}; pub use num::{Round, Fractional, Real, RealExt};
pub use num::{Bitwise, BitCount, Bounded}; pub use num::{Bitwise, BitCount, Bounded};
pub use num::{Primitive, PrimitiveInt}; pub use num::{Primitive, Int, Float};
pub use num::{Int, Uint, Float};
pub use ptr::Ptr; pub use ptr::Ptr;
pub use to_str::ToStr; pub use to_str::ToStr;
pub use clone::Clone; pub use clone::Clone;

View File

@ -445,8 +445,6 @@ impl Bounded for T {
fn max_value() -> T { max_value } fn max_value() -> T { max_value }
} }
impl PrimitiveInt for T {}
impl Int for T {} impl Int for T {}
// String conversion functions and impl str -> num // String conversion functions and impl str -> num

View File

@ -217,23 +217,11 @@ pub trait Primitive: Num
/// ///
/// A collection of traits relevant to primitive signed and unsigned integers /// A collection of traits relevant to primitive signed and unsigned integers
/// ///
pub trait PrimitiveInt: Integer pub trait Int: Integer
+ Primitive + Primitive
+ Bounded + Bounded
+ Bitwise + Bitwise
+ BitCount {} + BitCount {}
///
/// Specialisation of `PrimitiveInt` for unsigned integers
///
pub trait Uint: PrimitiveInt
+ Unsigned {}
///
/// Specialisation of `PrimitiveInt` for signed integers
///
pub trait Int: PrimitiveInt
+ Signed {}
/// ///
/// Primitive floating point numbers. This trait should only be implemented /// Primitive floating point numbers. This trait should only be implemented

View File

@ -277,9 +277,7 @@ impl Bounded for T {
fn max_value() -> T { max_value } fn max_value() -> T { max_value }
} }
impl PrimitiveInt for T {} impl Int for T {}
impl Uint for T {}
// String conversion functions and impl str -> num // String conversion functions and impl str -> num

View File

@ -41,8 +41,7 @@ pub use num::{Num, NumCast};
pub use num::{Signed, Unsigned, Integer}; pub use num::{Signed, Unsigned, Integer};
pub use num::{Round, Fractional, Real, RealExt}; pub use num::{Round, Fractional, Real, RealExt};
pub use num::{Bitwise, BitCount, Bounded}; pub use num::{Bitwise, BitCount, Bounded};
pub use num::{Primitive, PrimitiveInt}; pub use num::{Primitive, Int, Float};
pub use num::{Int, Uint, Float};
pub use path::GenericPath; pub use path::GenericPath;
pub use path::Path; pub use path::Path;
pub use path::PosixPath; pub use path::PosixPath;