Skip to content

Commit 6efbbf2

Browse files
committed
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>() { … }
1 parent faaf3bf commit 6efbbf2

File tree

5 files changed

+8
-26
lines changed

5 files changed

+8
-26
lines changed

src/libcore/core.rc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ pub use num::{Num, NumCast};
107107
pub use num::{Signed, Unsigned, Integer};
108108
pub use num::{Round, Fractional, Real, RealExt};
109109
pub use num::{Bitwise, BitCount, Bounded};
110-
pub use num::{Primitive, PrimitiveInt};
111-
pub use num::{Int, Uint, Float};
110+
pub use num::{Primitive, Int, Float};
112111
pub use ptr::Ptr;
113112
pub use to_str::ToStr;
114113
pub use clone::Clone;

src/libcore/num/int-template.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,6 @@ impl Bounded for T {
445445
fn max_value() -> T { max_value }
446446
}
447447
448-
impl PrimitiveInt for T {}
449-
450448
impl Int for T {}
451449
452450
// String conversion functions and impl str -> num

src/libcore/num/num.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,23 +217,11 @@ pub trait Primitive: Num
217217
///
218218
/// A collection of traits relevant to primitive signed and unsigned integers
219219
///
220-
pub trait PrimitiveInt: Integer
221-
+ Primitive
222-
+ Bounded
223-
+ Bitwise
224-
+ BitCount {}
225-
226-
///
227-
/// Specialisation of `PrimitiveInt` for unsigned integers
228-
///
229-
pub trait Uint: PrimitiveInt
230-
+ Unsigned {}
231-
232-
///
233-
/// Specialisation of `PrimitiveInt` for signed integers
234-
///
235-
pub trait Int: PrimitiveInt
236-
+ Signed {}
220+
pub trait Int: Integer
221+
+ Primitive
222+
+ Bounded
223+
+ Bitwise
224+
+ BitCount {}
237225

238226
///
239227
/// Primitive floating point numbers. This trait should only be implemented

src/libcore/num/uint-template.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,7 @@ impl Bounded for T {
277277
fn max_value() -> T { max_value }
278278
}
279279
280-
impl PrimitiveInt for T {}
281-
282-
impl Uint for T {}
280+
impl Int for T {}
283281
284282
// String conversion functions and impl str -> num
285283

src/libcore/prelude.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ pub use num::{Num, NumCast};
4141
pub use num::{Signed, Unsigned, Integer};
4242
pub use num::{Round, Fractional, Real, RealExt};
4343
pub use num::{Bitwise, BitCount, Bounded};
44-
pub use num::{Primitive, PrimitiveInt};
45-
pub use num::{Int, Uint, Float};
44+
pub use num::{Primitive, Int, Float};
4645
pub use path::GenericPath;
4746
pub use path::Path;
4847
pub use path::PosixPath;

0 commit comments

Comments
 (0)