Skip to content

Commit 844fbd8

Browse files
committed
core: Make some functions pure
1 parent 561511e commit 844fbd8

File tree

12 files changed

+21
-21
lines changed

12 files changed

+21
-21
lines changed

src/libcore/i16.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ fn range(lo: i16, hi: i16, it: fn(i16)) {
3131
}
3232

3333
#[doc = "Computes the bitwise complement"]
34-
fn compl(i: i16) -> i16 {
34+
pure fn compl(i: i16) -> i16 {
3535
u16::compl(i as u16) as i16
3636
}
3737

3838
#[doc = "Computes the absolute value"]
39-
fn abs(i: i16) -> i16 {
39+
pure fn abs(i: i16) -> i16 {
4040
if negative(i) { -i } else { i }
4141
}

src/libcore/i32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ fn range(lo: i32, hi: i32, it: fn(i32)) {
3131
}
3232

3333
#[doc = "Computes the bitwise complement"]
34-
fn compl(i: i32) -> i32 {
34+
pure fn compl(i: i32) -> i32 {
3535
u32::compl(i as u32) as i32
3636
}
3737

3838
#[doc = "Computes the absolute value"]
39-
fn abs(i: i32) -> i32 {
39+
pure fn abs(i: i32) -> i32 {
4040
if negative(i) { -i } else { i }
4141
}

src/libcore/i64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ fn range(lo: i64, hi: i64, it: fn(i64)) {
3131
}
3232

3333
#[doc = "Computes the bitwise complement"]
34-
fn compl(i: i64) -> i64 {
34+
pure fn compl(i: i64) -> i64 {
3535
u64::compl(i as u64) as i64
3636
}
3737

3838
#[doc = "Computes the absolute value"]
39-
fn abs(i: i64) -> i64 {
39+
pure fn abs(i: i64) -> i64 {
4040
if negative(i) { -i } else { i }
4141
}

src/libcore/i8.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ fn range(lo: i8, hi: i8, it: fn(i8)) {
3131
}
3232

3333
#[doc = "Computes the bitwise complement"]
34-
fn compl(i: i8) -> i8 {
34+
pure fn compl(i: i8) -> i8 {
3535
u8::compl(i as u8) as i8
3636
}
3737

3838
#[doc = "Computes the absolute value"]
39-
fn abs(i: i8) -> i8 {
39+
pure fn abs(i: i8) -> i8 {
4040
if negative(i) { -i } else { i }
4141
}

src/libcore/int.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pure fn nonnegative(x: int) -> bool { ret x >= 0; }
3737

3838
// FIXME: Make sure this works with negative integers.
3939
#[doc = "Produce a uint suitable for use in a hash table"]
40-
fn hash(x: int) -> uint { ret x as uint; }
40+
pure fn hash(x: int) -> uint { ret x as uint; }
4141

4242
#[doc = "Iterate over the range `[lo..hi)`"]
4343
fn range(lo: int, hi: int, it: fn(int)) {
@@ -107,7 +107,7 @@ fn pow(base: int, exponent: uint) -> int {
107107
}
108108

109109
#[doc = "Computes the bitwise complement"]
110-
fn compl(i: int) -> int {
110+
pure fn compl(i: int) -> int {
111111
uint::compl(i as uint) as int
112112
}
113113

src/libcore/result.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Get the value out of a successful result
1515
1616
If the result is an error
1717
"]
18-
fn get<T: copy, U>(res: result<T, U>) -> T {
18+
pure fn get<T: copy, U>(res: result<T, U>) -> T {
1919
alt res {
2020
ok(t) { t }
2121
err(_) {
@@ -33,7 +33,7 @@ Get the value out of an error result
3333
3434
If the result is not an error
3535
"]
36-
fn get_err<T, U: copy>(res: result<T, U>) -> U {
36+
pure fn get_err<T, U: copy>(res: result<T, U>) -> U {
3737
alt res {
3838
err(u) { u }
3939
ok(_) {

src/libcore/tuple.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
fn first<T:copy, U:copy>(pair: (T, U)) -> T {
1+
pure fn first<T:copy, U:copy>(pair: (T, U)) -> T {
22
let (t, _) = pair;
33
ret t;
44
}
55

6-
fn second<T:copy, U:copy>(pair: (T, U)) -> U {
6+
pure fn second<T:copy, U:copy>(pair: (T, U)) -> U {
77
let (_, u) = pair;
88
ret u;
99
}
1010

11-
fn swap<T:copy, U:copy>(pair: (T, U)) -> (U, T) {
11+
pure fn swap<T:copy, U:copy>(pair: (T, U)) -> (U, T) {
1212
let (t, u) = pair;
1313
ret (u, t);
1414
}

src/libcore/u16.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ fn range(lo: u16, hi: u16, it: fn(u16)) {
3131
}
3232

3333
#[doc = "Computes the bitwise complement"]
34-
fn compl(i: u16) -> u16 {
34+
pure fn compl(i: u16) -> u16 {
3535
max_value ^ i
3636
}

src/libcore/u32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn range(lo: u32, hi: u32, it: fn(u32)) {
2626
}
2727

2828
#[doc = "Computes the bitwise complement"]
29-
fn compl(i: u32) -> u32 {
29+
pure fn compl(i: u32) -> u32 {
3030
max_value ^ i
3131
}
3232

src/libcore/u64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@ fn from_str(buf: str, radix: u64) -> option<u64> {
8282
}
8383

8484
#[doc = "Computes the bitwise complement"]
85-
fn compl(i: u64) -> u64 {
85+
pure fn compl(i: u64) -> u64 {
8686
max_value ^ i
8787
}

src/libcore/u8.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn range(lo: u8, hi: u8, it: fn(u8)) {
2828
}
2929

3030
#[doc = "Computes the bitwise complement"]
31-
fn compl(i: u8) -> u8 {
31+
pure fn compl(i: u8) -> u8 {
3232
max_value ^ i
3333
}
3434

src/libcore/uint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ is either `x/y` or `x/y + 1`.
7474
pure fn div_floor(x: uint, y: uint) -> uint { ret x / y; }
7575

7676
#[doc = "Produce a uint suitable for use in a hash table"]
77-
fn hash(x: uint) -> uint { ret x; }
77+
pure fn hash(x: uint) -> uint { ret x; }
7878

7979
#[doc = "Iterate over the range [`lo`..`hi`)"]
8080
#[inline(always)]
@@ -188,7 +188,7 @@ fn to_str(num: uint, radix: uint) -> str {
188188
fn str(i: uint) -> str { ret to_str(i, 10u); }
189189

190190
#[doc = "Computes the bitwise complement"]
191-
fn compl(i: uint) -> uint {
191+
pure fn compl(i: uint) -> uint {
192192
max_value ^ i
193193
}
194194

0 commit comments

Comments
 (0)