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 a542258 commit 5f904d2Copy full SHA for 5f904d2
src/libcore/int-template.rs
@@ -89,11 +89,12 @@ fn parse_buf(buf: [u8], radix: uint) -> option<T> {
89
fn from_str(s: str) -> option<T> { parse_buf(str::bytes(s), 10u) }
90
91
#[doc = "Convert to a string in a given base"]
92
-fn to_str(n: T, radix: uint) -> str {
93
- assert (0u < radix && radix <= 16u);
94
- ret if n < 0 as T {
95
- "-" + uint::to_str(-n as uint, radix)
96
- } else { uint::to_str(n as uint, radix) };
+fn to_str(n: T, radix: uint) -> str unsafe {
+ to_str_bytes(n, radix) {|slice|
+ vec::unpack_slice(slice) {|p, len|
+ str::unsafe::from_buf_len(p, len)
+ }
97
98
}
99
100
fn to_str_bytes<U>(n: T, radix: uint, f: fn([u8]/&) -> U) -> U {
0 commit comments