Replace uses of str::unsafe_from_byte

This commit is contained in:
Kevin Cantu 2012-01-24 23:47:32 -08:00
parent 2496dccae4
commit 9750e83a17
3 changed files with 5 additions and 5 deletions

View file

@ -39,7 +39,7 @@ fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) ->
ast::ident { ast::ident {
let rslt = ""; let rslt = "";
while !is_last(peek(st) as char) { while !is_last(peek(st) as char) {
rslt += str::unsafe_from_byte(next(st)); rslt += str::from_byte(next(st));
} }
ret rslt; ret rslt;
} }
@ -226,7 +226,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
while peek(st) as char != ']' { while peek(st) as char != ']' {
let name = ""; let name = "";
while peek(st) as char != '=' { while peek(st) as char != '=' {
name += str::unsafe_from_byte(next(st)); name += str::from_byte(next(st));
} }
st.pos = st.pos + 1u; st.pos = st.pos + 1u;
fields += [{ident: name, mt: parse_mt(st, conv)}]; fields += [{ident: name, mt: parse_mt(st, conv)}];

View file

@ -146,7 +146,7 @@ Function: unsafe_from_byte
Converts a byte to a string. Does not verify that the byte is Converts a byte to a string. Does not verify that the byte is
valid UTF-8. valid UTF-8.
FIXME: rename to 'from_byte' FIXME: REMOVE.
*/ */
fn unsafe_from_byte(u: u8) -> str { unsafe_from_bytes([u]) } fn unsafe_from_byte(u: u8) -> str { unsafe_from_bytes([u]) }

View file

@ -236,12 +236,12 @@ fn to_str(num: uint, radix: uint) -> str {
if n == 0u { ret "0"; } if n == 0u { ret "0"; }
let s: str = ""; let s: str = "";
while n != 0u { while n != 0u {
s += str::unsafe_from_byte(digit(n % radix) as u8); s += str::from_byte(digit(n % radix) as u8);
n /= radix; n /= radix;
} }
let s1: str = ""; let s1: str = "";
let len: uint = str::byte_len(s); let len: uint = str::byte_len(s);
while len != 0u { len -= 1u; s1 += str::unsafe_from_byte(s[len]); } while len != 0u { len -= 1u; s1 += str::from_byte(s[len]); }
ret s1; ret s1;
} }