Use loop instead of while(true) in libraries and compiler itself
And remove spurious fails/unreachable() calls.
This commit is contained in:
@@ -64,7 +64,7 @@ fn parse_buf(buf: [u8], radix: uint) -> option<int> {
|
||||
start = 1u;
|
||||
}
|
||||
let mut n = 0;
|
||||
while true {
|
||||
loop {
|
||||
alt char::to_digit(buf[i] as char, radix) {
|
||||
some(d) { n += (d as int) * power; }
|
||||
none { ret none; }
|
||||
@@ -72,8 +72,7 @@ fn parse_buf(buf: [u8], radix: uint) -> option<int> {
|
||||
power *= radix as int;
|
||||
if i <= start { ret some(n); }
|
||||
i -= 1u;
|
||||
}
|
||||
fail;
|
||||
};
|
||||
}
|
||||
|
||||
#[doc = "Parse a string to an int"]
|
||||
|
||||
@@ -70,7 +70,7 @@ fn from_str(buf: str, radix: u64) -> option<u64> {
|
||||
if str::len(buf) == 0u { ret none; }
|
||||
let mut i = str::len(buf) - 1u;
|
||||
let mut power = 1u64, n = 0u64;
|
||||
while true {
|
||||
loop {
|
||||
alt char::to_digit(buf[i] as char, radix as uint) {
|
||||
some(d) { n += d as u64 * power; }
|
||||
none { ret none; }
|
||||
@@ -78,8 +78,7 @@ fn from_str(buf: str, radix: u64) -> option<u64> {
|
||||
power *= radix;
|
||||
if i == 0u { ret some(n); }
|
||||
i -= 1u;
|
||||
}
|
||||
fail;
|
||||
};
|
||||
}
|
||||
|
||||
#[doc = "Computes the bitwise complement"]
|
||||
|
||||
@@ -133,7 +133,7 @@ fn parse_buf(buf: [u8], radix: uint) -> option<uint> {
|
||||
let mut i = vec::len(buf) - 1u;
|
||||
let mut power = 1u;
|
||||
let mut n = 0u;
|
||||
while true {
|
||||
loop {
|
||||
alt char::to_digit(buf[i] as char, radix) {
|
||||
some(d) { n += d * power; }
|
||||
none { ret none; }
|
||||
@@ -141,8 +141,7 @@ fn parse_buf(buf: [u8], radix: uint) -> option<uint> {
|
||||
power *= radix;
|
||||
if i == 0u { ret some(n); }
|
||||
i -= 1u;
|
||||
}
|
||||
fail;
|
||||
};
|
||||
}
|
||||
|
||||
#[doc = "Parse a string to an int"]
|
||||
|
||||
Reference in New Issue
Block a user