about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-03-15 13:57:26 -0700
committerBrian Anderson <banderson@mozilla.com>2012-03-15 13:57:26 -0700
commit844fbd83da4143bae253f3969d7b2cccb258bebc (patch)
tree40c3e330818a990af5e378a2a0eff12d42df076e /src
parent561511e62813840e930ff60e6918ccaea4f00f00 (diff)
downloadrust-844fbd83da4143bae253f3969d7b2cccb258bebc.tar.gz
rust-844fbd83da4143bae253f3969d7b2cccb258bebc.zip
core: Make some functions pure
Diffstat (limited to 'src')
-rw-r--r--src/libcore/i16.rs4
-rw-r--r--src/libcore/i32.rs4
-rw-r--r--src/libcore/i64.rs4
-rw-r--r--src/libcore/i8.rs4
-rw-r--r--src/libcore/int.rs4
-rw-r--r--src/libcore/result.rs4
-rw-r--r--src/libcore/tuple.rs6
-rw-r--r--src/libcore/u16.rs2
-rw-r--r--src/libcore/u32.rs2
-rw-r--r--src/libcore/u64.rs2
-rw-r--r--src/libcore/u8.rs2
-rw-r--r--src/libcore/uint.rs4
12 files changed, 21 insertions, 21 deletions
diff --git a/src/libcore/i16.rs b/src/libcore/i16.rs
index b3f10a3a979..30116f92b0e 100644
--- a/src/libcore/i16.rs
+++ b/src/libcore/i16.rs
@@ -31,11 +31,11 @@ fn range(lo: i16, hi: i16, it: fn(i16)) {
 }
 
 #[doc = "Computes the bitwise complement"]
-fn compl(i: i16) -> i16 {
+pure fn compl(i: i16) -> i16 {
     u16::compl(i as u16) as i16
 }
 
 #[doc = "Computes the absolute value"]
-fn abs(i: i16) -> i16 {
+pure fn abs(i: i16) -> i16 {
     if negative(i) { -i } else { i }
 }
diff --git a/src/libcore/i32.rs b/src/libcore/i32.rs
index 1e151f5d39d..faa2c71821a 100644
--- a/src/libcore/i32.rs
+++ b/src/libcore/i32.rs
@@ -31,11 +31,11 @@ fn range(lo: i32, hi: i32, it: fn(i32)) {
 }
 
 #[doc = "Computes the bitwise complement"]
-fn compl(i: i32) -> i32 {
+pure fn compl(i: i32) -> i32 {
     u32::compl(i as u32) as i32
 }
 
 #[doc = "Computes the absolute value"]
-fn abs(i: i32) -> i32 {
+pure fn abs(i: i32) -> i32 {
     if negative(i) { -i } else { i }
 }
diff --git a/src/libcore/i64.rs b/src/libcore/i64.rs
index 1eecf56c0b7..a2e39a4b679 100644
--- a/src/libcore/i64.rs
+++ b/src/libcore/i64.rs
@@ -31,11 +31,11 @@ fn range(lo: i64, hi: i64, it: fn(i64)) {
 }
 
 #[doc = "Computes the bitwise complement"]
-fn compl(i: i64) -> i64 {
+pure fn compl(i: i64) -> i64 {
     u64::compl(i as u64) as i64
 }
 
 #[doc = "Computes the absolute value"]
-fn abs(i: i64) -> i64 {
+pure fn abs(i: i64) -> i64 {
     if negative(i) { -i } else { i }
 }
diff --git a/src/libcore/i8.rs b/src/libcore/i8.rs
index f88ca0f5892..6f6e375d010 100644
--- a/src/libcore/i8.rs
+++ b/src/libcore/i8.rs
@@ -31,11 +31,11 @@ fn range(lo: i8, hi: i8, it: fn(i8)) {
 }
 
 #[doc = "Computes the bitwise complement"]
-fn compl(i: i8) -> i8 {
+pure fn compl(i: i8) -> i8 {
     u8::compl(i as u8) as i8
 }
 
 #[doc = "Computes the absolute value"]
-fn abs(i: i8) -> i8 {
+pure fn abs(i: i8) -> i8 {
     if negative(i) { -i } else { i }
 }
diff --git a/src/libcore/int.rs b/src/libcore/int.rs
index 174d62926f0..00e7357c244 100644
--- a/src/libcore/int.rs
+++ b/src/libcore/int.rs
@@ -37,7 +37,7 @@ pure fn nonnegative(x: int) -> bool { ret x >= 0; }
 
 // FIXME: Make sure this works with negative integers.
 #[doc = "Produce a uint suitable for use in a hash table"]
-fn hash(x: int) -> uint { ret x as uint; }
+pure fn hash(x: int) -> uint { ret x as uint; }
 
 #[doc = "Iterate over the range `[lo..hi)`"]
 fn range(lo: int, hi: int, it: fn(int)) {
@@ -107,7 +107,7 @@ fn pow(base: int, exponent: uint) -> int {
 }
 
 #[doc = "Computes the bitwise complement"]
-fn compl(i: int) -> int {
+pure fn compl(i: int) -> int {
     uint::compl(i as uint) as int
 }
 
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 0efd38904a0..09b9b8ccedc 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -15,7 +15,7 @@ Get the value out of a successful result
 
 If the result is an error
 "]
-fn get<T: copy, U>(res: result<T, U>) -> T {
+pure fn get<T: copy, U>(res: result<T, U>) -> T {
     alt res {
       ok(t) { t }
       err(_) {
@@ -33,7 +33,7 @@ Get the value out of an error result
 
 If the result is not an error
 "]
-fn get_err<T, U: copy>(res: result<T, U>) -> U {
+pure fn get_err<T, U: copy>(res: result<T, U>) -> U {
     alt res {
       err(u) { u }
       ok(_) {
diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs
index 2f92ae08f0e..e7fdaf8f2ba 100644
--- a/src/libcore/tuple.rs
+++ b/src/libcore/tuple.rs
@@ -1,14 +1,14 @@
-fn first<T:copy, U:copy>(pair: (T, U)) -> T {
+pure fn first<T:copy, U:copy>(pair: (T, U)) -> T {
     let (t, _) = pair;
     ret t;
 }
 
-fn second<T:copy, U:copy>(pair: (T, U)) -> U {
+pure fn second<T:copy, U:copy>(pair: (T, U)) -> U {
     let (_, u) = pair;
     ret u;
 }
 
-fn swap<T:copy, U:copy>(pair: (T, U)) -> (U, T) {
+pure fn swap<T:copy, U:copy>(pair: (T, U)) -> (U, T) {
     let (t, u) = pair;
     ret (u, t);
 }
diff --git a/src/libcore/u16.rs b/src/libcore/u16.rs
index 2d69a523e66..eb0965057e7 100644
--- a/src/libcore/u16.rs
+++ b/src/libcore/u16.rs
@@ -31,6 +31,6 @@ fn range(lo: u16, hi: u16, it: fn(u16)) {
 }
 
 #[doc = "Computes the bitwise complement"]
-fn compl(i: u16) -> u16 {
+pure fn compl(i: u16) -> u16 {
     max_value ^ i
 }
diff --git a/src/libcore/u32.rs b/src/libcore/u32.rs
index da60b7a5a1d..dfe88b19e6a 100644
--- a/src/libcore/u32.rs
+++ b/src/libcore/u32.rs
@@ -26,7 +26,7 @@ fn range(lo: u32, hi: u32, it: fn(u32)) {
 }
 
 #[doc = "Computes the bitwise complement"]
-fn compl(i: u32) -> u32 {
+pure fn compl(i: u32) -> u32 {
     max_value ^ i
 }
 
diff --git a/src/libcore/u64.rs b/src/libcore/u64.rs
index 98bb98a0daa..a7542894452 100644
--- a/src/libcore/u64.rs
+++ b/src/libcore/u64.rs
@@ -82,6 +82,6 @@ fn from_str(buf: str, radix: u64) -> option<u64> {
 }
 
 #[doc = "Computes the bitwise complement"]
-fn compl(i: u64) -> u64 {
+pure fn compl(i: u64) -> u64 {
     max_value ^ i
 }
diff --git a/src/libcore/u8.rs b/src/libcore/u8.rs
index 397d78572a3..613b1d6b15b 100644
--- a/src/libcore/u8.rs
+++ b/src/libcore/u8.rs
@@ -28,7 +28,7 @@ fn range(lo: u8, hi: u8, it: fn(u8)) {
 }
 
 #[doc = "Computes the bitwise complement"]
-fn compl(i: u8) -> u8 {
+pure fn compl(i: u8) -> u8 {
     max_value ^ i
 }
 
diff --git a/src/libcore/uint.rs b/src/libcore/uint.rs
index 88230bea094..d2b04d78dca 100644
--- a/src/libcore/uint.rs
+++ b/src/libcore/uint.rs
@@ -74,7 +74,7 @@ is either `x/y` or `x/y + 1`.
 pure fn div_floor(x: uint, y: uint) -> uint { ret x / y; }
 
 #[doc = "Produce a uint suitable for use in a hash table"]
-fn hash(x: uint) -> uint { ret x; }
+pure fn hash(x: uint) -> uint { ret x; }
 
 #[doc = "Iterate over the range [`lo`..`hi`)"]
 #[inline(always)]
@@ -188,7 +188,7 @@ fn to_str(num: uint, radix: uint) -> str {
 fn str(i: uint) -> str { ret to_str(i, 10u); }
 
 #[doc = "Computes the bitwise complement"]
-fn compl(i: uint) -> uint {
+pure fn compl(i: uint) -> uint {
     max_value ^ i
 }