Skip to content

Commit 9b95d51

Browse files
committed
core: Remove old template files
1 parent 16f72df commit 9b95d51

File tree

27 files changed

+306
-588
lines changed

27 files changed

+306
-588
lines changed

src/libcore/core.rc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,52 +46,52 @@ Implicitly, all crates behave as if they included the following prologue:
4646

4747
/// Operations and constants for `int`
4848
#[path = "int-template.rs"]
49-
#[merge = "int-template/intb.rs"]
49+
#[merge = "int-template/int.rs"]
5050
pub mod int;
5151

5252
/// Operations and constants for `i8`
5353
#[path = "int-template.rs"]
54-
#[merge = "int-template/i8b.rs"]
54+
#[merge = "int-template/i8.rs"]
5555
pub mod i8;
5656

5757
/// Operations and constants for `i16`
5858
#[path = "int-template.rs"]
59-
#[merge = "int-template/i16b.rs"]
59+
#[merge = "int-template/i16.rs"]
6060
pub mod i16;
6161

6262
/// Operations and constants for `i32`
6363
#[path = "int-template.rs"]
64-
#[merge = "int-template/i32b.rs"]
64+
#[merge = "int-template/i32.rs"]
6565
pub mod i32;
6666

6767
/// Operations and constants for `i64`
6868
#[path = "int-template.rs"]
69-
#[merge = "int-template/i64b.rs"]
69+
#[merge = "int-template/i64.rs"]
7070
pub mod i64;
7171

7272
/// Operations and constants for `uint`
7373
#[path = "uint-template.rs"]
74-
#[merge = "uint-template/uintb.rs"]
74+
#[merge = "uint-template/uint.rs"]
7575
pub mod uint;
7676

7777
/// Operations and constants for `u8`
7878
#[path = "uint-template.rs"]
79-
#[merge = "uint-template/u8b.rs"]
79+
#[merge = "uint-template/u8.rs"]
8080
pub mod u8;
8181

8282
/// Operations and constants for `u16`
8383
#[path = "uint-template.rs"]
84-
#[merge = "uint-template/u16b.rs"]
84+
#[merge = "uint-template/u16.rs"]
8585
pub mod u16;
8686

8787
/// Operations and constants for `u32`
8888
#[path = "uint-template.rs"]
89-
#[merge = "uint-template/u32b.rs"]
89+
#[merge = "uint-template/u32.rs"]
9090
pub mod u32;
9191

9292
/// Operations and constants for `u64`
9393
#[path = "uint-template.rs"]
94-
#[merge = "uint-template/u64b.rs"]
94+
#[merge = "uint-template/u64.rs"]
9595
pub mod u64;
9696

9797

@@ -121,7 +121,7 @@ pub mod iter;
121121
pub mod logging;
122122
pub mod option;
123123
#[path="iter-trait.rs"]
124-
#[merge = "iter-trait/optionb.rs"]
124+
#[merge = "iter-trait/option.rs"]
125125
pub mod option_iter;
126126
pub mod result;
127127
pub mod to_str;
@@ -134,11 +134,11 @@ pub mod clone;
134134

135135
pub mod dvec;
136136
#[path="iter-trait.rs"]
137-
#[merge = "iter-trait/dvecb.rs"]
137+
#[merge = "iter-trait/dvec.rs"]
138138
pub mod dvec_iter;
139139
pub mod dlist;
140140
#[path="iter-trait.rs"]
141-
#[merge = "iter-trait/dlistb.rs"]
141+
#[merge = "iter-trait/dlist.rs"]
142142
pub mod dlist_iter;
143143
pub mod send_map;
144144

src/libcore/int-template/i16.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
pub type T = i16;
2-
pub const bits: uint = u16::bits;
1+
mod inst {
2+
pub type T = i16;
3+
pub const bits: uint = u16::bits;
4+
}

src/libcore/int-template/i16b.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/libcore/int-template/i32.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
pub type T = i32;
2-
pub const bits: uint = u32::bits;
1+
mod inst {
2+
pub type T = i32;
3+
pub const bits: uint = u32::bits;
4+
}

src/libcore/int-template/i32b.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/libcore/int-template/i64.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
pub type T = i64;
2-
pub const bits: uint = u64::bits;
1+
mod inst {
2+
pub type T = i64;
3+
pub const bits: uint = u64::bits;
4+
}

src/libcore/int-template/i64b.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/libcore/int-template/i8.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
pub type T = i8;
2-
pub const bits: uint = u8::bits;
1+
mod inst {
2+
pub type T = i8;
3+
pub const bits: uint = u8::bits;
4+
}

src/libcore/int-template/i8b.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/libcore/int-template/int.rs

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,45 @@
1-
pub type T = int;
2-
pub const bits: uint = uint::bits;
1+
pub use inst::pow;
32

4-
/// Returns `base` raised to the power of `exponent`
5-
pub fn pow(base: int, exponent: uint) -> int {
6-
if exponent == 0u { return 1; } //Not mathemtically true if ~[base == 0]
7-
if base == 0 { return 0; }
8-
let mut my_pow = exponent;
9-
let mut acc = 1;
10-
let mut multiplier = base;
11-
while(my_pow > 0u) {
12-
if my_pow % 2u == 1u {
13-
acc *= multiplier;
14-
}
15-
my_pow /= 2u;
16-
multiplier *= multiplier;
3+
mod inst {
4+
pub type T = int;
5+
pub const bits: uint = uint::bits;
6+
7+
/// Returns `base` raised to the power of `exponent`
8+
pub fn pow(base: int, exponent: uint) -> int {
9+
if exponent == 0u {
10+
//Not mathemtically true if ~[base == 0]
11+
return 1;
12+
}
13+
if base == 0 { return 0; }
14+
let mut my_pow = exponent;
15+
let mut acc = 1;
16+
let mut multiplier = base;
17+
while(my_pow > 0u) {
18+
if my_pow % 2u == 1u {
19+
acc *= multiplier;
20+
}
21+
my_pow /= 2u;
22+
multiplier *= multiplier;
23+
}
24+
return acc;
1725
}
18-
return acc;
19-
}
2026

21-
#[test]
22-
fn test_pow() {
23-
assert (pow(0, 0u) == 1);
24-
assert (pow(0, 1u) == 0);
25-
assert (pow(0, 2u) == 0);
26-
assert (pow(-1, 0u) == 1);
27-
assert (pow(1, 0u) == 1);
28-
assert (pow(-3, 2u) == 9);
29-
assert (pow(-3, 3u) == -27);
30-
assert (pow(4, 9u) == 262144);
31-
}
27+
#[test]
28+
fn test_pow() {
29+
assert (pow(0, 0u) == 1);
30+
assert (pow(0, 1u) == 0);
31+
assert (pow(0, 2u) == 0);
32+
assert (pow(-1, 0u) == 1);
33+
assert (pow(1, 0u) == 1);
34+
assert (pow(-3, 2u) == 9);
35+
assert (pow(-3, 3u) == -27);
36+
assert (pow(4, 9u) == 262144);
37+
}
3238

33-
#[test]
34-
fn test_overflows() {
35-
assert (max_value > 0);
36-
assert (min_value <= 0);
37-
assert (min_value + max_value + 1 == 0);
38-
}
39+
#[test]
40+
fn test_overflows() {
41+
assert (max_value > 0);
42+
assert (min_value <= 0);
43+
assert (min_value + max_value + 1 == 0);
44+
}
45+
}

src/libcore/int-template/intb.rs

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/libcore/iter-trait/dlist.rs

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1-
#[allow(non_camel_case_types)]
2-
pub type IMPL_T<A> = dlist::DList<A>;
1+
mod inst {
2+
#[allow(non_camel_case_types)]
3+
pub type IMPL_T<A> = dlist::DList<A>;
34

4-
/**
5-
* Iterates through the current contents.
6-
*
7-
* Attempts to access this dlist during iteration are allowed (to allow for
8-
* e.g. breadth-first search with in-place enqueues), but removing the current
9-
* node is forbidden.
10-
*/
11-
pub pure fn EACH<A>(self: &IMPL_T<A>, f: fn(v: &A) -> bool) {
12-
let mut link = self.peek_n();
13-
while option::is_some(&link) {
14-
let nobe = option::get(link);
15-
assert nobe.linked;
16-
if !f(&nobe.data) { break; }
17-
// Check (weakly) that the user didn't do a remove.
18-
if self.size == 0 {
19-
fail ~"The dlist became empty during iteration??"
5+
/**
6+
* Iterates through the current contents.
7+
*
8+
* Attempts to access this dlist during iteration are allowed (to
9+
* allow for e.g. breadth-first search with in-place enqueues), but
10+
* removing the current node is forbidden.
11+
*/
12+
pub pure fn EACH<A>(self: &IMPL_T<A>, f: fn(v: &A) -> bool) {
13+
let mut link = self.peek_n();
14+
while option::is_some(&link) {
15+
let nobe = option::get(link);
16+
assert nobe.linked;
17+
if !f(&nobe.data) { break; }
18+
// Check (weakly) that the user didn't do a remove.
19+
if self.size == 0 {
20+
fail ~"The dlist became empty during iteration??"
21+
}
22+
if !nobe.linked ||
23+
(!((nobe.prev.is_some()
24+
|| box::ptr_eq(*self.hd.expect(~"headless dlist?"),
25+
*nobe))
26+
&& (nobe.next.is_some()
27+
|| box::ptr_eq(*self.tl.expect(~"tailless dlist?"),
28+
*nobe)))) {
29+
fail ~"Removing a dlist node during iteration is forbidden!"
30+
}
31+
link = nobe.next_link();
2032
}
21-
if !nobe.linked ||
22-
(!((nobe.prev.is_some()
23-
|| box::ptr_eq(*self.hd.expect(~"headless dlist?"), *nobe)) &&
24-
(nobe.next.is_some()
25-
|| box::ptr_eq(*self.tl.expect(~"tailless dlist?"), *nobe)))) {
26-
fail ~"Removing a dlist node during iteration is forbidden!"
27-
}
28-
link = nobe.next_link();
2933
}
30-
}
3134

32-
pub pure fn SIZE_HINT<A>(self: &IMPL_T<A>) -> Option<uint> {
33-
Some(self.len())
34-
}
35+
pub pure fn SIZE_HINT<A>(self: &IMPL_T<A>) -> Option<uint> {
36+
Some(self.len())
37+
}
38+
}

src/libcore/iter-trait/dlistb.rs

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)