Convert std::uint to istrs. Issue #855
This commit is contained in:
parent
69e6abf9ce
commit
ee2a11eb4f
19 changed files with 99 additions and 73 deletions
|
|
@ -67,7 +67,8 @@ fn get_doc(d: doc, tg: uint) -> doc {
|
|||
alt maybe_get_doc(d, tg) {
|
||||
some(d) { ret d; }
|
||||
none. {
|
||||
log_err "failed to find block with tag " + uint::to_str(tg, 10u);
|
||||
log_err "failed to find block with tag "
|
||||
+ istr::to_estr(uint::to_str(tg, 10u));
|
||||
fail;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ mod rt {
|
|||
ret if prec == 0u && num == 0u {
|
||||
""
|
||||
} else {
|
||||
let s = uint::to_str(num, radix);
|
||||
let s = istr::to_estr(uint::to_str(num, radix));
|
||||
let len = str::char_len(s);
|
||||
if len < prec {
|
||||
let diff = prec - len;
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ iter range(lo: int, hi: int) -> int {
|
|||
fn to_str(n: int, radix: uint) -> str {
|
||||
assert (0u < radix && radix <= 16u);
|
||||
ret if n < 0 {
|
||||
"-" + uint::to_str(-n as uint, radix)
|
||||
} else { uint::to_str(n as uint, radix) };
|
||||
"-" + istr::to_estr(uint::to_str(-n as uint, radix))
|
||||
} else { istr::to_estr(uint::to_str(n as uint, radix)) };
|
||||
}
|
||||
fn str(i: int) -> str { ret to_str(i, 10u); }
|
||||
|
||||
|
|
|
|||
|
|
@ -338,7 +338,8 @@ obj new_writer(out: buf_writer) {
|
|||
out.write(str::bytes(str::from_char(ch)));
|
||||
}
|
||||
fn write_int(n: int) { out.write(str::bytes(int::to_str(n, 10u))); }
|
||||
fn write_uint(n: uint) { out.write(str::bytes(uint::to_str(n, 10u))); }
|
||||
fn write_uint(n: uint) { out.write(str::bytes(
|
||||
istr::to_estr(uint::to_str(n, 10u)))); }
|
||||
fn write_bytes(bytes: &[u8]) { out.write(bytes); }
|
||||
fn write_le_uint(n: uint, size: uint) {
|
||||
out.write(uint_to_le_bytes(n, size));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ export eq, lteq, hash, is_empty, is_not_empty, is_whitespace, byte_len,
|
|||
index, rindex, find, starts_with, ends_with, substr, slice, split,
|
||||
concat, connect, to_upper, replace, char_slice, trim_left, trim_right, trim,
|
||||
unshift_char, shift_char, pop_char, push_char, is_utf8, from_chars, to_chars,
|
||||
char_len, char_at, bytes, is_ascii, shift_byte, pop_byte, unsafe_from_bytes;
|
||||
char_len, char_at, bytes, is_ascii, shift_byte, pop_byte, unsafe_from_byte,
|
||||
unsafe_from_bytes;
|
||||
|
||||
export from_estr, to_estr;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ fn format_addr(ip: ip_addr) -> str {
|
|||
}
|
||||
|
||||
fn parse_addr(ip: str) -> ip_addr {
|
||||
let parts = vec::map(uint::from_str, str::split(ip, "."[0]));
|
||||
let parts = vec::map(
|
||||
{ |&s| uint::from_str(istr::from_estr(s)) },
|
||||
str::split(ip, "."[0]));
|
||||
if vec::len(parts) != 4u { fail "Too many dots in IP address"; }
|
||||
for i in parts { if i > 255u { fail "Invalid IP Address part."; } }
|
||||
ipv4(parts[0] as u8, parts[1] as u8, parts[2] as u8, parts[3] as u8)
|
||||
|
|
|
|||
|
|
@ -220,7 +220,9 @@ fn mk_sha1() -> sha1 {
|
|||
fn result_str() -> str {
|
||||
let r = mk_result(st);
|
||||
let s = "";
|
||||
for b: u8 in r { s += uint::to_str(b as uint, 16u); }
|
||||
for b: u8 in r {
|
||||
s += istr::to_estr(uint::to_str(b as uint, 16u));
|
||||
}
|
||||
ret s;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,9 +56,9 @@ fn parse_buf(buf: &[u8], radix: uint) -> uint {
|
|||
fail;
|
||||
}
|
||||
|
||||
fn from_str(s: &str) -> uint { parse_buf(str::bytes(s), 10u) }
|
||||
fn from_str(s: &istr) -> uint { parse_buf(istr::bytes(s), 10u) }
|
||||
|
||||
fn to_str(num: uint, radix: uint) -> str {
|
||||
fn to_str(num: uint, radix: uint) -> istr {
|
||||
let n = num;
|
||||
assert (0u < radix && radix <= 16u);
|
||||
fn digit(n: uint) -> char {
|
||||
|
|
@ -82,18 +82,18 @@ fn to_str(num: uint, radix: uint) -> str {
|
|||
_ { fail }
|
||||
};
|
||||
}
|
||||
if n == 0u { ret "0"; }
|
||||
let s: str = "";
|
||||
if n == 0u { ret ~"0"; }
|
||||
let s: istr = ~"";
|
||||
while n != 0u {
|
||||
s += str::unsafe_from_byte(digit(n % radix) as u8);
|
||||
s += istr::unsafe_from_byte(digit(n % radix) as u8);
|
||||
n /= radix;
|
||||
}
|
||||
let s1: str = "";
|
||||
let len: uint = str::byte_len(s);
|
||||
while len != 0u { len -= 1u; s1 += str::unsafe_from_byte(s[len]); }
|
||||
let s1: istr = ~"";
|
||||
let len: uint = istr::byte_len(s);
|
||||
while len != 0u { len -= 1u; s1 += istr::unsafe_from_byte(s[len]); }
|
||||
ret s1;
|
||||
}
|
||||
fn str(i: uint) -> str { ret to_str(i, 10u); }
|
||||
fn str(i: uint) -> istr { ret to_str(i, 10u); }
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue