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:
parent
faaf3bf149
commit
6efbbf2e14
@ -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;
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user