提交 6efbbf2e 编写于 作者: B Brendan Zabarauskas

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>() { … }
上级 faaf3bf1
......@@ -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;
......
......@@ -445,8 +445,6 @@ fn min_value() -> T { min_value }
fn max_value() -> T { max_value }
}
impl PrimitiveInt for T {}
impl Int for T {}
// String conversion functions and impl str -> num
......
......@@ -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
......
......@@ -277,9 +277,7 @@ fn min_value() -> T { min_value }
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
......
......@@ -41,8 +41,7 @@
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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册