Make some standard library pieces no longer dependent on mutable parameters, which rustc doesn't support

This commit is contained in:
Patrick Walton 2011-03-18 13:32:15 -07:00
parent e8938f5fb2
commit 8aa946ff5e
2 changed files with 14 additions and 10 deletions

View File

@ -17,14 +17,15 @@ fn negative(int x) -> bool { ret x < 0; }
fn nonpositive(int x) -> bool { ret x <= 0; } fn nonpositive(int x) -> bool { ret x <= 0; }
fn nonnegative(int x) -> bool { ret x >= 0; } fn nonnegative(int x) -> bool { ret x >= 0; }
iter range(mutable int lo, int hi) -> int { iter range(int lo, int hi) -> int {
while (lo < hi) { let int lo_ = lo;
put lo; while (lo_ < hi) {
lo += 1; put lo_;
lo_ += 1;
} }
} }
fn to_str(mutable int n, uint radix) -> str fn to_str(int n, uint radix) -> str
{ {
check (0u < radix && radix <= 16u); check (0u < radix && radix <= 16u);
if (n < 0) { if (n < 0) {

View File

@ -12,10 +12,11 @@ fn ne(uint x, uint y) -> bool { ret x != y; }
fn ge(uint x, uint y) -> bool { ret x >= y; } fn ge(uint x, uint y) -> bool { ret x >= y; }
fn gt(uint x, uint y) -> bool { ret x > y; } fn gt(uint x, uint y) -> bool { ret x > y; }
iter range(mutable uint lo, uint hi) -> uint { iter range(uint lo, uint hi) -> uint {
while (lo < hi) { auto lo_ = lo;
put lo; while (lo_ < hi) {
lo += 1u; put lo_;
lo_ += 1u;
} }
} }
@ -32,8 +33,10 @@ fn next_power_of_two(uint n) -> uint {
ret tmp + 1u; ret tmp + 1u;
} }
fn to_str(mutable uint n, uint radix) -> str fn to_str(uint num, uint radix) -> str
{ {
auto n = num;
check (0u < radix && radix <= 16u); check (0u < radix && radix <= 16u);
fn digit(uint n) -> char { fn digit(uint n) -> char {
alt (n) { alt (n) {