aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-03-18 13:32:15 -0700
committerPatrick Walton <[email protected]>2011-03-18 13:32:15 -0700
commit8aa946ff5e312543a4e3903ee0d3580fbd8d2887 (patch)
tree4d2854c507ef62adc7027d7694549c300e92233d
parentrustc: Unify over alt expressions (diff)
downloadrust-8aa946ff5e312543a4e3903ee0d3580fbd8d2887.tar.xz
rust-8aa946ff5e312543a4e3903ee0d3580fbd8d2887.zip
Make some standard library pieces no longer dependent on mutable parameters, which rustc doesn't support
-rw-r--r--src/lib/_int.rs11
-rw-r--r--src/lib/_uint.rs13
2 files changed, 14 insertions, 10 deletions
diff --git a/src/lib/_int.rs b/src/lib/_int.rs
index ef1b3b66..dfd2204d 100644
--- a/src/lib/_int.rs
+++ b/src/lib/_int.rs
@@ -17,14 +17,15 @@ fn negative(int x) -> bool { ret x < 0; }
fn nonpositive(int x) -> bool { ret x <= 0; }
fn nonnegative(int x) -> bool { ret x >= 0; }
-iter range(mutable int lo, int hi) -> int {
- while (lo < hi) {
- put lo;
- lo += 1;
+iter range(int lo, int hi) -> int {
+ let int lo_ = lo;
+ while (lo_ < hi) {
+ 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);
if (n < 0) {
diff --git a/src/lib/_uint.rs b/src/lib/_uint.rs
index 5e8d4b97..f456b733 100644
--- a/src/lib/_uint.rs
+++ b/src/lib/_uint.rs
@@ -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 gt(uint x, uint y) -> bool { ret x > y; }
-iter range(mutable uint lo, uint hi) -> uint {
- while (lo < hi) {
- put lo;
- lo += 1u;
+iter range(uint lo, uint hi) -> uint {
+ auto lo_ = lo;
+ while (lo_ < hi) {
+ put lo_;
+ lo_ += 1u;
}
}
@@ -32,8 +33,10 @@ fn next_power_of_two(uint n) -> uint {
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);
fn digit(uint n) -> char {
alt (n) {