Skip to content

Commit b52a4b4

Browse files
committed
core: Make core.rc more readable. Cleanup
1 parent 3ed9fbd commit b52a4b4

29 files changed

+215
-221
lines changed

src/libcore/bool.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub fn all_values(blk: fn(v: bool)) {
6565
/// converts truth value to an 8 bit byte
6666
pub pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
6767

68+
#[cfg(notest)]
6869
impl bool : cmp::Eq {
6970
pure fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
7071
pure fn ne(&self, other: &bool) -> bool { (*self) != (*other) }

src/libcore/box.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ pub pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
2727
unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) }
2828
}
2929

30+
#[cfg(notest)]
3031
impl<T:Eq> @const T : Eq {
3132
pure fn eq(&self, other: &@const T) -> bool { *(*self) == *(*other) }
3233
pure fn ne(&self, other: &@const T) -> bool { *(*self) != *(*other) }
3334
}
3435

36+
#[cfg(notest)]
3537
impl<T:Ord> @const T : Ord {
3638
pure fn lt(&self, other: &@const T) -> bool { *(*self) < *(*other) }
3739
pure fn le(&self, other: &@const T) -> bool { *(*self) <= *(*other) }

src/libcore/char.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ pub pure fn cmp(a: char, b: char) -> int {
180180
else { 0 }
181181
}
182182

183+
#[cfg(notest)]
183184
impl char : Eq {
184185
pure fn eq(&self, other: &char) -> bool { (*self) == (*other) }
185186
pure fn ne(&self, other: &char) -> bool { (*self) != (*other) }

src/libcore/cmp.rs

Lines changed: 25 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -14,70 +14,35 @@ and `Eq` to overload the `==` and `!=` operators.
1414
#[forbid(deprecated_mode)];
1515
#[forbid(deprecated_pattern)];
1616

17-
pub use nounittest::*;
18-
pub use unittest::*;
19-
20-
/// Interfaces used for comparison.
21-
22-
// Awful hack to work around duplicate lang items in core test.
23-
#[cfg(notest)]
24-
mod nounittest {
25-
/**
26-
* Trait for values that can be compared for a sort-order.
27-
*
28-
* Eventually this may be simplified to only require
29-
* an `le` method, with the others generated from
30-
* default implementations.
31-
*/
32-
#[lang="ord"]
33-
pub trait Ord {
34-
pure fn lt(&self, other: &self) -> bool;
35-
pure fn le(&self, other: &self) -> bool;
36-
pure fn ge(&self, other: &self) -> bool;
37-
pure fn gt(&self, other: &self) -> bool;
38-
}
39-
40-
#[lang="eq"]
41-
/**
42-
* Trait for values that can be compared for equality
43-
* and inequality.
44-
*
45-
* Eventually this may be simplified to only require
46-
* an `eq` method, with the other generated from
47-
* a default implementation.
48-
*/
49-
#[lang="eq"]
50-
pub trait Eq {
51-
pure fn eq(&self, other: &self) -> bool;
52-
pure fn ne(&self, other: &self) -> bool;
53-
}
17+
/**
18+
* Trait for values that can be compared for equality
19+
* and inequality.
20+
*
21+
* Eventually this may be simplified to only require
22+
* an `eq` method, with the other generated from
23+
* a default implementation.
24+
*/
25+
#[lang="eq"]
26+
pub trait Eq {
27+
pure fn eq(&self, other: &self) -> bool;
28+
pure fn ne(&self, other: &self) -> bool;
5429
}
5530

56-
#[cfg(test)]
57-
mod nounittest {
58-
#[legacy_exports];}
59-
60-
#[cfg(test)]
61-
mod unittest {
62-
#[legacy_exports];
63-
64-
pub trait Ord {
65-
pure fn lt(&self, other: &self) -> bool;
66-
pure fn le(&self, other: &self) -> bool;
67-
pure fn ge(&self, other: &self) -> bool;
68-
pure fn gt(&self, other: &self) -> bool;
69-
}
70-
71-
pub trait Eq {
72-
pure fn eq(&self, other: &self) -> bool;
73-
pure fn ne(&self, other: &self) -> bool;
74-
}
31+
/**
32+
* Trait for values that can be compared for a sort-order.
33+
*
34+
* Eventually this may be simplified to only require
35+
* an `le` method, with the others generated from
36+
* default implementations.
37+
*/
38+
#[lang="ord"]
39+
pub trait Ord {
40+
pure fn lt(&self, other: &self) -> bool;
41+
pure fn le(&self, other: &self) -> bool;
42+
pure fn ge(&self, other: &self) -> bool;
43+
pure fn gt(&self, other: &self) -> bool;
7544
}
7645

77-
#[cfg(notest)]
78-
mod unittest {
79-
#[legacy_exports];}
80-
8146
pub pure fn lt<T: Ord>(v1: &T, v2: &T) -> bool {
8247
(*v1).lt(v2)
8348
}

0 commit comments

Comments
 (0)