diff options
| author | Stefan Plantikow <stefan.plantikow@googlemail.com> | 2011-12-16 18:18:34 +0100 |
|---|---|---|
| committer | Stefan Plantikow <stefan.plantikow@googlemail.com> | 2011-12-16 18:18:34 +0100 |
| commit | 7d786318a1b0f9315164716b46306d68e3b9560f (patch) | |
| tree | 279d9fbf3953e6b8ddda824fd8aa56b318d82c4d /src | |
| parent | bfbaadc694141935660fb73bbc1800389ede18e9 (diff) | |
| download | rust-7d786318a1b0f9315164716b46306d68e3b9560f.tar.gz rust-7d786318a1b0f9315164716b46306d68e3b9560f.zip | |
std: declared fns as pure where sensible
Diffstat (limited to 'src')
| -rw-r--r-- | src/libstd/bitv.rs | 2 | ||||
| -rw-r--r-- | src/libstd/list.rs | 6 | ||||
| -rw-r--r-- | src/libstd/posix_fs.rs | 1 | ||||
| -rw-r--r-- | src/libstd/rope.rs | 2 | ||||
| -rw-r--r-- | src/libstd/unicode.rs | 6 |
5 files changed, 9 insertions, 8 deletions
diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 4b726703085..a8e6d98b3cf 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -128,7 +128,7 @@ Function: get Retreive the value at index `i` */ -fn get(v: t, i: uint) -> bool { +pure fn get(v: t, i: uint) -> bool { assert (i < v.nbits); let bits = uint_bits; let w = i / bits; diff --git a/src/libstd/list.rs b/src/libstd/list.rs index d0c7582426a..67025cc90ac 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -112,7 +112,7 @@ Function: tail Returns all but the first element of a list */ -fn tail<copy T>(ls: list<T>) -> list<T> { +pure fn tail<copy T>(ls: list<T>) -> list<T> { alt ls { cons(_, tl) { ret *tl; } nil. { fail "list empty" } } } @@ -121,7 +121,7 @@ Function: head Returns the first element of a list */ -fn head<copy T>(ls: list<T>) -> T { +pure fn head<copy T>(ls: list<T>) -> T { alt ls { cons(hd, _) { ret hd; } nil. { fail "list empty" } } } @@ -130,7 +130,7 @@ Function: append Appends one list to another */ -fn append<copy T>(l: list<T>, m: list<T>) -> list<T> { +pure fn append<copy T>(l: list<T>, m: list<T>) -> list<T> { alt l { nil. { ret m; } cons(x, xs) { let rest = append(*xs, m); ret cons(x, @rest); } diff --git a/src/libstd/posix_fs.rs b/src/libstd/posix_fs.rs index befa4c9829c..e774650f980 100644 --- a/src/libstd/posix_fs.rs +++ b/src/libstd/posix_fs.rs @@ -30,6 +30,7 @@ fn list_dir(path: str) -> [str] { } +// FIXME make pure when str::char_at is fn path_is_absolute(p: str) -> bool { ret str::char_at(p, 0u) == '/'; } const path_sep: char = '/'; diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 2872aa6c4f6..bd07b6a8bc7 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -310,7 +310,7 @@ Returns: A negative value if `left < right`, 0 if eq(left, right) or a positive value if `left > right` - */ +*/ fn cmp(left: rope, right: rope) -> int { alt((left, right)) { (node::empty., node::empty.) { ret 0; } diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs index 5038721d26e..a3d11cbc55b 100644 --- a/src/libstd/unicode.rs +++ b/src/libstd/unicode.rs @@ -151,16 +151,16 @@ mod icu { #[link_name = "icuuc"] #[abi = "cdecl"] native mod libicu { - fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool; + pure fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool; } } -fn is_XID_start(c: char) -> bool { +pure fn is_XID_start(c: char) -> bool { ret icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) == icu::TRUE; } -fn is_XID_continue(c: char) -> bool { +pure fn is_XID_continue(c: char) -> bool { ret icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) == icu::TRUE; } |
