Skip to content

Commit 7d78631

Browse files
committed
std: declared fns as pure where sensible
1 parent bfbaadc commit 7d78631

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/libstd/bitv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Function: get
128128
129129
Retreive the value at index `i`
130130
*/
131-
fn get(v: t, i: uint) -> bool {
131+
pure fn get(v: t, i: uint) -> bool {
132132
assert (i < v.nbits);
133133
let bits = uint_bits;
134134
let w = i / bits;

src/libstd/list.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Function: tail
112112
113113
Returns all but the first element of a list
114114
*/
115-
fn tail<copy T>(ls: list<T>) -> list<T> {
115+
pure fn tail<copy T>(ls: list<T>) -> list<T> {
116116
alt ls { cons(_, tl) { ret *tl; } nil. { fail "list empty" } }
117117
}
118118

@@ -121,7 +121,7 @@ Function: head
121121
122122
Returns the first element of a list
123123
*/
124-
fn head<copy T>(ls: list<T>) -> T {
124+
pure fn head<copy T>(ls: list<T>) -> T {
125125
alt ls { cons(hd, _) { ret hd; } nil. { fail "list empty" } }
126126
}
127127

@@ -130,7 +130,7 @@ Function: append
130130
131131
Appends one list to another
132132
*/
133-
fn append<copy T>(l: list<T>, m: list<T>) -> list<T> {
133+
pure fn append<copy T>(l: list<T>, m: list<T>) -> list<T> {
134134
alt l {
135135
nil. { ret m; }
136136
cons(x, xs) { let rest = append(*xs, m); ret cons(x, @rest); }

src/libstd/posix_fs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ fn list_dir(path: str) -> [str] {
3030

3131
}
3232

33+
// FIXME make pure when str::char_at is
3334
fn path_is_absolute(p: str) -> bool { ret str::char_at(p, 0u) == '/'; }
3435

3536
const path_sep: char = '/';

src/libstd/rope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ Returns:
310310
311311
A negative value if `left < right`, 0 if eq(left, right) or a positive
312312
value if `left > right`
313-
*/
313+
*/
314314
fn cmp(left: rope, right: rope) -> int {
315315
alt((left, right)) {
316316
(node::empty., node::empty.) { ret 0; }

src/libstd/unicode.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ mod icu {
151151
#[link_name = "icuuc"]
152152
#[abi = "cdecl"]
153153
native mod libicu {
154-
fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
154+
pure fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
155155
}
156156
}
157157

158-
fn is_XID_start(c: char) -> bool {
158+
pure fn is_XID_start(c: char) -> bool {
159159
ret icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START)
160160
== icu::TRUE;
161161
}
162162

163-
fn is_XID_continue(c: char) -> bool {
163+
pure fn is_XID_continue(c: char) -> bool {
164164
ret icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START)
165165
== icu::TRUE;
166166
}

0 commit comments

Comments
 (0)