diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 0fc869d1b41a93b0b8077bcc30ce0a12a375cf93..af4b752f4dd1a7e556168154eb94d1acf637ff30 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -123,7 +123,7 @@ fn all_values(blk: block(v: t)) { An u8 whose first bit is set if `if_true(v)` holds */ -fn to_bit(v: t) -> u8 { if v { 1u8 } else { 0u8 } } +pure fn to_bit(v: t) -> u8 { if v { 1u8 } else { 0u8 } } // Local Variables: // mode: rust; diff --git a/src/libcore/box.rs b/src/libcore/box.rs index 6682fe17284ac429a2000635d04d02b418d8327f..23b5889bc6a4e5f6ce31574dec81e5841e47f716 100644 --- a/src/libcore/box.rs +++ b/src/libcore/box.rs @@ -10,7 +10,7 @@ Determine if two shared boxes point to the same object */ -fn ptr_eq(a: @T, b: @T) -> bool { +pure fn ptr_eq(a: @T, b: @T) -> bool { // FIXME: ptr::addr_of unsafe { let a_ptr: uint = unsafe::reinterpret_cast(a); diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 5ff7681ae8ab484dc377d2f71541d5dcc24d283a..2648c8481dfa17134100188232cbde7aa2e3a8fa 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -122,7 +122,7 @@ Convert a char to the corresponding digit. Returns none when the character is not a valid hexadecimal digit. */ -fn maybe_digit(c: char) -> option::t { +pure fn maybe_digit(c: char) -> option::t { alt c { '0' to '9' { option::some(c as u8 - ('0' as u8)) } 'a' to 'z' { option::some(c as u8 + 10u8 - ('a' as u8)) } @@ -143,7 +143,7 @@ fn maybe_digit(c: char) -> option::t { Returns: -1 if ab */ -fn cmp(a: char, b: char) -> int { +pure fn cmp(a: char, b: char) -> int { ret if b > a { -1 } else if b < a { 1 } else { 0 } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 403cb47f47e645d608a2fe04f1ea27f89fbd888f..39e68a01519bff70c1c83cf9d5795a30a616e3dd 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -30,7 +30,7 @@ Fails if the value equals `none`. */ -fn get(opt: t) -> T { +pure fn get(opt: t) -> T { alt opt { some(x) { ret x; } none. { fail "option none"; } } } @@ -61,7 +61,7 @@ fn map(f: block(T) -> U, opt: t) -> t { Returns the contained value or a default */ -fn from_maybe(def: T, opt: t) -> T { +pure fn from_maybe(def: T, opt: t) -> T { alt opt { some(x) { x } none. { def } } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 8a532fcc75323437b5aabd007eefebbfdabeb8ba..802297223e9bce490dda0f670d91c9e45bff7119 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -26,14 +26,14 @@ Bytewise string equality */ -fn eq(&&a: str, &&b: str) -> bool { a == b } +pure fn eq(&&a: str, &&b: str) -> bool { a == b } /* Function: lteq Bytewise less than or equal */ -fn lteq(&&a: str, &&b: str) -> bool { a <= b } +pure fn lteq(&&a: str, &&b: str) -> bool { a <= b } /* Function: hash @@ -131,7 +131,7 @@ fn is_whitespace(s: str) -> bool { Returns the length in bytes of a string */ -fn byte_len(s: str) -> uint unsafe { +pure fn byte_len(s: str) -> uint unsafe { let v: [u8] = unsafe::reinterpret_cast(s); let vlen = vec::len(v); unsafe::leak(v); @@ -261,7 +261,7 @@ fn from_chars(chs: [char]) -> str { FIXME: What does this function do? */ -fn utf8_char_width(b: u8) -> uint { +pure fn utf8_char_width(b: u8) -> uint { let byte: uint = b as uint; if byte < 128u { ret 1u; } if byte < 192u { diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 3b4a3b8c64378eeae0c037f9c453d26018ffd0bf..9c8b097211173a63bb518885834d8e1117af8e9d 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -42,7 +42,7 @@ fn get_type_desc() -> *type_desc { Get a string representing the platform-dependent last error */ fn last_os_error() -> str { - ret rustrt::last_os_error(); + rustrt::last_os_error() } /* diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index d8f89b3b27bc943407e23048c94832c913faa933..d056eb8d04dcc048843de134b4a3e7aa33970741 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -181,7 +181,7 @@ fn from_mut(v: [mutable T]) -> [T] { Predicates: (v) */ -fn head(v: [const T]) : is_not_empty(v) -> T { ret v[0]; } +pure fn head(v: [const T]) : is_not_empty(v) -> T { ret v[0]; } /* Function: tail @@ -221,7 +221,7 @@ fn init(v: [const T]) -> [T] { An option containing the last element of `v` if `v` is not empty, or none if `v` is empty. */ -fn last(v: [const T]) -> option::t { +pure fn last(v: [const T]) -> option::t { if len(v) == 0u { ret none; } ret some(v[len(v) - 1u]); } @@ -234,7 +234,7 @@ fn last(v: [const T]) -> option::t { Predicates: (v) */ -fn last_total(v: [const T]) : is_not_empty(v) -> T { +pure fn last_total(v: [const T]) : is_not_empty(v) -> T { ret v[len(v) - 1u]; }