We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 73044b3 commit fef8314Copy full SHA for fef8314
src/lib/_uint.rs
@@ -34,14 +34,22 @@ fn next_power_of_two(uint n) -> uint {
34
}
35
36
fn parse_buf(vec[u8] buf, uint radix) -> uint {
37
+ if (_vec.len[u8](buf) == 0u) {
38
+ log_err "parse_buf(): buf is empty";
39
+ fail;
40
+ }
41
+
42
auto i = _vec.len[u8](buf) - 1u;
43
auto power = 1u;
44
auto n = 0u;
45
while (true) {
46
n += (((buf.(i)) - ('0' as u8)) as uint) * power;
47
power *= radix;
48
if (i == 0u) { ret n; }
49
+ i -= 1u;
50
51
52
53
54
55
fn to_str(uint num, uint radix) -> str
0 commit comments