]> git.lizzy.rs Git - rust.git/commitdiff
rm obsolete integer to_str{,_radix} free functions
authorDaniel Micay <danielmicay@gmail.com>
Sun, 18 Aug 2013 02:47:54 +0000 (22:47 -0400)
committerDaniel Micay <danielmicay@gmail.com>
Wed, 21 Aug 2013 02:05:03 +0000 (22:05 -0400)
27 files changed:
doc/rust.md
doc/tutorial.md
src/libextra/crypto/digest.rs
src/libextra/md4.rs
src/libextra/num/bigint.rs
src/libextra/time.rs
src/librustc/driver/driver.rs
src/librustc/metadata/encoder.rs
src/librustc/metadata/tyencode.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/infer/to_str.rs
src/libstd/hash.rs
src/libstd/num/int_macros.rs
src/libstd/num/strconv.rs
src/libstd/num/uint_macros.rs
src/libstd/prelude.rs
src/libstd/unstable/extfmt.rs
src/libsyntax/print/pprust.rs
src/test/bench/core-set.rs
src/test/bench/core-uint-to-str.rs
src/test/bench/shootout-pfib.rs
src/test/run-pass/monad.rs
src/test/run-pass/reflect-visit-data.rs
src/test/run-pass/static-impl.rs
src/test/run-pass/trait-generic.rs
src/test/run-pass/trait-to-str.rs

index 8b06c170f035f90c3c735de91d1dc7b26275ebae..4cd9dc3a1162d445865bc87eb311a82984b619d7 100644 (file)
@@ -2864,17 +2864,16 @@ the vtable pointer for the `T` implementation of `R`, and the pointer value of `
 An example of an object type:
 
 ~~~~~~~~
-# use std::int;
 trait Printable {
-  fn to_str(&self) -> ~str;
+  fn to_string(&self) -> ~str;
 }
 
 impl Printable for int {
-  fn to_str(&self) -> ~str { int::to_str(*self) }
+  fn to_string(&self) -> ~str { self.to_str() }
 }
 
 fn print(a: @Printable) {
-   println(a.to_str());
+   println(a.to_string());
 }
 
 fn main() {
index 1813356a1f309ed0d1a900a76fac8472005ae15e..958c15737615a3bbed9117d2a0a492a65709aaef 100644 (file)
@@ -555,12 +555,11 @@ while cake_amount > 0 {
 `loop` denotes an infinite loop, and is the preferred way of writing `while true`:
 
 ~~~~
-use std::int;
-let mut x = 5;
+let mut x = 5u;
 loop {
     x += x - 3;
     if x % 5 == 0 { break; }
-    println(int::to_str(x));
+    println(x.to_str());
 }
 ~~~~
 
index c7f228af332a3bdf246af290ebbc173c2b32df29..d2d6b540cff4cf50bc6b10f67974776823e02d28 100644 (file)
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::uint;
 use std::vec;
 
 
@@ -71,7 +70,7 @@ fn result_str(&mut self) -> ~str {
 fn to_hex(rr: &[u8]) -> ~str {
     let mut s = ~"";
     for b in rr.iter() {
-        let hex = uint::to_str_radix(*b as uint, 16u);
+        let hex = (*b as uint).to_str_radix(16u);
         if hex.len() == 1 {
             s.push_char('0');
         }
index 2c60be4451974f06ea8bbd1da25979b55ca45d6b..abce22f98c6bf712c591f53177760533b8be639e 100644 (file)
@@ -9,7 +9,6 @@
 // except according to those terms.
 
 
-use std::uint;
 use std::vec;
 
 struct Quad {
@@ -121,7 +120,7 @@ fn app(a: u32, b: u32, c: u32, d: u32, f: &fn(u32)) {
             if byte <= 16u8 {
                 result.push_char('0')
             }
-            result.push_str(uint::to_str_radix(byte as uint, 16u));
+            result.push_str((byte as uint).to_str_radix(16u));
             i += 1u32;
         }
     }
index 354696ef42060642e23ee3fa6b7e58a756cd57b4..c86c4dd07ed2f2034da4c13ddcf2ea4d7aa78b27 100644 (file)
@@ -525,7 +525,7 @@ fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> ~str {
             if v.is_empty() { return ~"0" }
             let mut s = str::with_capacity(v.len() * l);
             for n in v.rev_iter() {
-                let ss = uint::to_str_radix(*n as uint, radix);
+                let ss = (*n as uint).to_str_radix(radix);
                 s.push_str("0".repeat(l - ss.len()));
                 s.push_str(ss);
             }
index ab35bf2386ca4d89ed9345c7004ff4a2f5ce182f..257d941e4afff6d3db6c579555179e265013e8b3 100644 (file)
@@ -10,8 +10,6 @@
 
 #[allow(missing_doc)];
 
-
-use std::int;
 use std::io;
 use std::num;
 use std::str;
@@ -824,7 +822,7 @@ fn parse_type(ch: char, tm: &Tm) -> ~str {
           //'U' {}
           'u' => {
             let i = tm.tm_wday as int;
-            int::to_str(if i == 0 { 7 } else { i })
+            (if i == 0 { 7 } else { i }).to_str()
           }
           //'V' {}
           'v' => {
@@ -834,10 +832,10 @@ fn parse_type(ch: char, tm: &Tm) -> ~str {
                 parse_type('Y', tm))
           }
           //'W' {}
-          'w' => int::to_str(tm.tm_wday as int),
+          'w' => (tm.tm_wday as int).to_str(),
           //'X' {}
           //'x' {}
-          'Y' => int::to_str(tm.tm_year as int + 1900),
+          'Y' => (tm.tm_year as int + 1900).to_str(),
           'y' => fmt!("%02d", (tm.tm_year as int + 1900) % 100),
           'Z' => tm.tm_zone.clone(),
           'z' => {
index cdafb7400e1a294e4e6fd9c3061f56bc64ed2fe7..1ddebbb428010d3cbc8baf906ada3db835ad6b29 100644 (file)
@@ -26,7 +26,6 @@
 use util::ppaux;
 
 use std::hashmap::{HashMap,HashSet};
-use std::int;
 use std::io;
 use std::os;
 use std::vec;
@@ -454,21 +453,21 @@ fn ann_identified_post(node: pprust::ann_node) {
         match node {
           pprust::node_item(s, item) => {
             pp::space(s.s);
-            pprust::synth_comment(s, int::to_str(item.id));
+            pprust::synth_comment(s, item.id.to_str());
           }
           pprust::node_block(s, ref blk) => {
             pp::space(s.s);
             pprust::synth_comment(
-                s, ~"block " + int::to_str(blk.id));
+                s, ~"block " + blk.id.to_str());
           }
           pprust::node_expr(s, expr) => {
             pp::space(s.s);
-            pprust::synth_comment(s, int::to_str(expr.id));
+            pprust::synth_comment(s, expr.id.to_str());
             pprust::pclose(s);
           }
           pprust::node_pat(s, pat) => {
             pp::space(s.s);
-            pprust::synth_comment(s, ~"pat " + int::to_str(pat.id));
+            pprust::synth_comment(s, ~"pat " + pat.id.to_str());
           }
         }
     }
index 4a3704dc3aa4e2a5198849d83b99847c2619b55e..eba01c8d399e86d5ee46a23c8ba0b60d6f82cb93 100644 (file)
@@ -25,7 +25,6 @@
 use std::hashmap::{HashMap, HashSet};
 use std::io;
 use std::str;
-use std::uint;
 use std::vec;
 use extra::flate;
 use extra::serialize::Encodable;
@@ -303,7 +302,7 @@ fn encode_disr_val(_: &EncodeContext,
                    ebml_w: &mut writer::Encoder,
                    disr_val: uint) {
     ebml_w.start_tag(tag_disr_val);
-    let s = uint::to_str(disr_val);
+    let s = disr_val.to_str();
     ebml_w.writer.write(s.as_bytes());
     ebml_w.end_tag();
 }
index 915729d254f94a7c602421e3055a9ceda56a94e4..5611808cc6d982225d6a7357f667633ea266b104 100644 (file)
@@ -17,7 +17,6 @@
 use std::hashmap::HashMap;
 use std::io::WriterUtil;
 use std::io;
-use std::uint;
 use syntax::abi::AbiSet;
 use syntax::ast;
 use syntax::ast::*;
@@ -324,7 +323,7 @@ fn enc_sty(w: @io::Writer, cx: @ctxt, st: &ty::sty) {
         w.write_char('p');
         w.write_str((cx.ds)(did));
         w.write_char('|');
-        w.write_str(uint::to_str(id));
+        w.write_str(id.to_str());
       }
       ty::ty_self(did) => {
         w.write_char('s');
index 95021d3b6e7866a139d794b16683083c8aa077b2..50b5140505ef35ed8114a3fc1efc84a283c81035 100644 (file)
@@ -71,7 +71,6 @@
 use std::hashmap::HashMap;
 use std::io;
 use std::libc::c_uint;
-use std::uint;
 use std::vec;
 use std::local_data;
 use extra::time;
@@ -719,7 +718,7 @@ fn iter_variant(cx: @mut Block, repr: &adt::Repr, av: ValueRef,
                   for variant in (*variants).iter() {
                       let variant_cx =
                           sub_block(cx, ~"enum-iter-variant-" +
-                                    uint::to_str(variant.disr_val));
+                                    variant.disr_val.to_str());
                       let variant_cx =
                           iter_variant(variant_cx, repr, av, *variant,
                                        substs.tps, |x,y,z| f(x,y,z));
index 67bd87824975b92a377a661e5f629e10bcd7ff55..96d12dbc3ac0e71f42330d5a77109b82a8e7a944 100644 (file)
@@ -33,7 +33,6 @@
 use std::ptr::to_unsafe_ptr;
 use std::to_bytes;
 use std::to_str::ToStr;
-use std::u32;
 use std::vec;
 use syntax::ast::*;
 use syntax::ast_util::is_local;
@@ -1944,7 +1943,7 @@ fn sub(&self, other: &TypeContents) -> TypeContents {
 
 impl ToStr for TypeContents {
     fn to_str(&self) -> ~str {
-        fmt!("TypeContents(%s)", u32::to_str_radix(self.bits, 2))
+        fmt!("TypeContents(%s)", self.bits.to_str_radix(2))
     }
 }
 
index 18594f35295a6ee4f5e488af9bbb092872c814c8..e2d6d588baed0e02e05099e5a5bc9f7cb7be8b4f 100644 (file)
@@ -17,7 +17,6 @@
 use middle::typeck::infer::unify::{Redirect, Root, VarValue};
 use util::ppaux::{mt_to_str, ty_to_str, trait_ref_to_str};
 
-use std::uint;
 use syntax::ast;
 
 pub trait InferStr {
@@ -72,7 +71,7 @@ fn inf_str(&self, cx: &InferCtxt) -> ~str {
         match *self {
           Redirect(ref vid) => fmt!("Redirect(%s)", vid.to_str()),
           Root(ref pt, rk) => fmt!("Root(%s, %s)", pt.inf_str(cx),
-                               uint::to_str_radix(rk, 10u))
+                               rk.to_str_radix(10u))
         }
     }
 }
index f3df42f7a4386ae70a87be1f6f2daa7b03646031..21b7ee321e8db2a1aa63d7d7b56c74879b1dc445 100644 (file)
@@ -27,8 +27,8 @@
 use rt::io::Writer;
 use str::OwnedStr;
 use to_bytes::IterBytes;
-use uint;
 use vec::ImmutableVector;
+use num::ToStrRadix;
 
 // Alias `SipState` to `State`.
 pub use State = hash::SipState;
@@ -386,7 +386,7 @@ fn result_str(&mut self) -> ~str {
         let r = self.result_bytes();
         let mut s = ~"";
         for b in r.iter() {
-            s.push_str(uint::to_str_radix(*b as uint, 16u));
+            s.push_str((*b as uint).to_str_radix(16u));
         }
         s
     }
@@ -407,8 +407,6 @@ mod tests {
     use super::*;
     use prelude::*;
 
-    use uint;
-
     // Hash just the bytes of the slice, without length prefix
     struct Bytes<'self>(&'self [u8]);
     impl<'self> IterBytes for Bytes<'self> {
@@ -496,7 +494,7 @@ fn test_siphash() {
         fn to_hex_str(r: &[u8, ..8]) -> ~str {
             let mut s = ~"";
             for b in r.iter() {
-                s.push_str(uint::to_str_radix(*b as uint, 16u));
+                s.push_str((*b as uint).to_str_radix(16u));
             }
             s
         }
index 0144f926534d029ce008256b1b4b17bd43495c68..4a7a5e32b32b2809cb2c7a4bc3ab4055dc7cfbbb 100644 (file)
@@ -525,35 +525,25 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U {
     f(buf.slice(0, cur))
 }
 
-/// Convert to a string in base 10.
-#[inline]
-pub fn to_str(num: $T) -> ~str {
-    to_str_radix(num, 10u)
-}
-
-/// Convert to a string in a given base.
-#[inline]
-pub fn to_str_radix(num: $T, radix: uint) -> ~str {
-    let mut buf: ~[u8] = ~[];
-    do strconv::int_to_str_bytes_common(num, radix, strconv::SignNeg) |i| {
-        buf.push(i);
-    }
-    // We know we generated valid utf-8, so we don't need to go through that
-    // check.
-    unsafe { str::raw::from_bytes_owned(buf) }
-}
-
 impl ToStr for $T {
+    /// Convert to a string in base 10.
     #[inline]
     fn to_str(&self) -> ~str {
-        to_str(*self)
+        self.to_str_radix(10)
     }
 }
 
 impl ToStrRadix for $T {
+    /// Convert to a string in a given base.
     #[inline]
     fn to_str_radix(&self, radix: uint) -> ~str {
-        to_str_radix(*self, radix)
+        let mut buf: ~[u8] = ~[];
+        do strconv::int_to_str_bytes_common(*self, radix, strconv::SignNeg) |i| {
+            buf.push(i);
+        }
+        // We know we generated valid utf-8, so we don't need to go through that
+        // check.
+        unsafe { str::raw::from_bytes_owned(buf) }
     }
 }
 
@@ -813,39 +803,39 @@ fn test_parse_bytes() {
 
     #[test]
     fn test_to_str() {
-        assert_eq!(to_str_radix(0 as $T, 10u), ~"0");
-        assert_eq!(to_str_radix(1 as $T, 10u), ~"1");
-        assert_eq!(to_str_radix(-1 as $T, 10u), ~"-1");
-        assert_eq!(to_str_radix(127 as $T, 16u), ~"7f");
-        assert_eq!(to_str_radix(100 as $T, 10u), ~"100");
+        assert_eq!((0 as $T).to_str_radix(10u), ~"0");
+        assert_eq!((1 as $T).to_str_radix(10u), ~"1");
+        assert_eq!((-1 as $T).to_str_radix(10u), ~"-1");
+        assert_eq!((127 as $T).to_str_radix(16u), ~"7f");
+        assert_eq!((100 as $T).to_str_radix(10u), ~"100");
 
     }
 
     #[test]
     fn test_int_to_str_overflow() {
         let mut i8_val: i8 = 127_i8;
-        assert_eq!(i8::to_str(i8_val), ~"127");
+        assert_eq!(i8_val.to_str(), ~"127");
 
         i8_val += 1 as i8;
-        assert_eq!(i8::to_str(i8_val), ~"-128");
+        assert_eq!(i8_val.to_str(), ~"-128");
 
         let mut i16_val: i16 = 32_767_i16;
-        assert_eq!(i16::to_str(i16_val), ~"32767");
+        assert_eq!(i16_val.to_str(), ~"32767");
 
         i16_val += 1 as i16;
-        assert_eq!(i16::to_str(i16_val), ~"-32768");
+        assert_eq!(i16_val.to_str(), ~"-32768");
 
         let mut i32_val: i32 = 2_147_483_647_i32;
-        assert_eq!(i32::to_str(i32_val), ~"2147483647");
+        assert_eq!(i32_val.to_str(), ~"2147483647");
 
         i32_val += 1 as i32;
-        assert_eq!(i32::to_str(i32_val), ~"-2147483648");
+        assert_eq!(i32_val.to_str(), ~"-2147483648");
 
         let mut i64_val: i64 = 9_223_372_036_854_775_807_i64;
-        assert_eq!(i64::to_str(i64_val), ~"9223372036854775807");
+        assert_eq!(i64_val.to_str(), ~"9223372036854775807");
 
         i64_val += 1 as i64;
-        assert_eq!(i64::to_str(i64_val), ~"-9223372036854775808");
+        assert_eq!(i64_val.to_str(), ~"-9223372036854775808");
     }
 
     #[test]
index 1f22343ad9c36063b8dc392120a4b3c451c15e45..6fba8a6dd137d2e6e8446c60a88c4fee525524ef 100644 (file)
@@ -708,14 +708,14 @@ fn from_str_issue5770() {
 mod bench {
     use extra::test::BenchHarness;
     use rand::{XorShiftRng,RngUtil};
-    use uint;
     use float;
+    use to_str::ToStr;
 
     #[bench]
     fn uint_to_str_rand(bh: &mut BenchHarness) {
         let mut rng = XorShiftRng::new();
         do bh.iter {
-            uint::to_str(rng.gen());
+            rng.gen::<uint>().to_str();
         }
     }
 
index 524b035c9f30928dff46665f948ae2050ea5278a..2bf41f4103d808455528bb361d5c9d084a07dd3a 100644 (file)
@@ -380,35 +380,25 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U {
     f(buf.slice(0, cur))
 }
 
-/// Convert to a string in base 10.
-#[inline]
-pub fn to_str(num: $T) -> ~str {
-    to_str_radix(num, 10u)
-}
-
-/// Convert to a string in a given base.
-#[inline]
-pub fn to_str_radix(num: $T, radix: uint) -> ~str {
-    let mut buf = ~[];
-    do strconv::int_to_str_bytes_common(num, radix, strconv::SignNone) |i| {
-        buf.push(i);
-    }
-    // We know we generated valid utf-8, so we don't need to go through that
-    // check.
-    unsafe { str::raw::from_bytes_owned(buf) }
-}
-
 impl ToStr for $T {
+    /// Convert to a string in base 10.
     #[inline]
     fn to_str(&self) -> ~str {
-        to_str(*self)
+        self.to_str_radix(10u)
     }
 }
 
 impl ToStrRadix for $T {
+    /// Convert to a string in a given base.
     #[inline]
     fn to_str_radix(&self, radix: uint) -> ~str {
-        to_str_radix(*self, radix)
+        let mut buf = ~[];
+        do strconv::int_to_str_bytes_common(*self, radix, strconv::SignNone) |i| {
+            buf.push(i);
+        }
+        // We know we generated valid utf-8, so we don't need to go through that
+        // check.
+        unsafe { str::raw::from_bytes_owned(buf) }
     }
 }
 
@@ -451,7 +441,6 @@ mod tests {
     use u32;
     use u64;
     use u8;
-    use uint;
 
     #[test]
     fn test_num() {
@@ -536,13 +525,13 @@ fn test_primitive() {
 
     #[test]
     pub fn test_to_str() {
-        assert_eq!(to_str_radix(0 as $T, 10u), ~"0");
-        assert_eq!(to_str_radix(1 as $T, 10u), ~"1");
-        assert_eq!(to_str_radix(2 as $T, 10u), ~"2");
-        assert_eq!(to_str_radix(11 as $T, 10u), ~"11");
-        assert_eq!(to_str_radix(11 as $T, 16u), ~"b");
-        assert_eq!(to_str_radix(255 as $T, 16u), ~"ff");
-        assert_eq!(to_str_radix(0xff as $T, 10u), ~"255");
+        assert_eq!((0 as $T).to_str_radix(10u), ~"0");
+        assert_eq!((1 as $T).to_str_radix(10u), ~"1");
+        assert_eq!((2 as $T).to_str_radix(10u), ~"2");
+        assert_eq!((11 as $T).to_str_radix(10u), ~"11");
+        assert_eq!((11 as $T).to_str_radix(16u), ~"b");
+        assert_eq!((255 as $T).to_str_radix(16u), ~"ff");
+        assert_eq!((0xff as $T).to_str_radix(10u), ~"255");
     }
 
     #[test]
@@ -575,28 +564,28 @@ pub fn test_parse_bytes() {
     #[test]
     fn test_uint_to_str_overflow() {
         let mut u8_val: u8 = 255_u8;
-        assert_eq!(u8::to_str(u8_val), ~"255");
+        assert_eq!(u8_val.to_str(), ~"255");
 
         u8_val += 1 as u8;
-        assert_eq!(u8::to_str(u8_val), ~"0");
+        assert_eq!(u8_val.to_str(), ~"0");
 
         let mut u16_val: u16 = 65_535_u16;
-        assert_eq!(u16::to_str(u16_val), ~"65535");
+        assert_eq!(u16_val.to_str(), ~"65535");
 
         u16_val += 1 as u16;
-        assert_eq!(u16::to_str(u16_val), ~"0");
+        assert_eq!(u16_val.to_str(), ~"0");
 
         let mut u32_val: u32 = 4_294_967_295_u32;
-        assert_eq!(u32::to_str(u32_val), ~"4294967295");
+        assert_eq!(u32_val.to_str(), ~"4294967295");
 
         u32_val += 1 as u32;
-        assert_eq!(u32::to_str(u32_val), ~"0");
+        assert_eq!(u32_val.to_str(), ~"0");
 
         let mut u64_val: u64 = 18_446_744_073_709_551_615_u64;
-        assert_eq!(u64::to_str(u64_val), ~"18446744073709551615");
+        assert_eq!(u64_val.to_str(), ~"18446744073709551615");
 
         u64_val += 1 as u64;
-        assert_eq!(u64::to_str(u64_val), ~"0");
+        assert_eq!(u64_val.to_str(), ~"0");
     }
 
     #[test]
@@ -638,14 +627,14 @@ fn test_uint_from_str_overflow() {
     #[should_fail]
     #[ignore(cfg(windows))]
     pub fn to_str_radix1() {
-        uint::to_str_radix(100u, 1u);
+        100u.to_str_radix(1u);
     }
 
     #[test]
     #[should_fail]
     #[ignore(cfg(windows))]
     pub fn to_str_radix37() {
-        uint::to_str_radix(100u, 37u);
+        100u.to_str_radix(37u);
     }
 
     #[test]
index 63f73002009312c21ccf7204f4c4aebba73bf72a..893c32e830a3738110f72bad9dbd9b6fc334e551 100644 (file)
@@ -58,7 +58,7 @@
 pub use num::{Algebraic, Trigonometric, Exponential, Hyperbolic};
 pub use num::{Integer, Fractional, Real, RealExt};
 pub use num::{Bitwise, BitCount, Bounded};
-pub use num::{Primitive, Int, Float};
+pub use num::{Primitive, Int, Float, ToStrRadix};
 pub use path::GenericPath;
 pub use path::Path;
 pub use path::PosixPath;
index 7b1f0e8ced8f2cbe8b7522664336f94d14cc6a17..83c12f0af5e1b92d7fbff75dc37107404ff585aa 100644 (file)
@@ -480,7 +480,6 @@ pub mod rt {
     use str;
     use sys;
     use num;
-    use uint;
     use vec;
     use option::{Some, None, Option};
 
@@ -593,7 +592,7 @@ pub fn uint_to_str_prec(num: uint, radix: uint, prec: uint) -> ~str {
         return if prec == 0u && num == 0u {
                 ~""
             } else {
-                let s = uint::to_str_radix(num, radix);
+                let s = num.to_str_radix(radix);
                 let len = s.char_len();
                 if len < prec {
                     let diff = prec - len;
index 6a3d829aca0b037d8231ef90cc04e2dac0066220..3bad1ed93842d5d41b997805fa5ce92114fef8a8 100644 (file)
@@ -28,7 +28,6 @@
 use print::pprust;
 
 use std::io;
-use std::u64;
 
 // The @ps is stored here to prevent recursive type.
 pub enum ann_node<'self> {
@@ -2035,24 +2034,24 @@ pub fn print_literal(s: @ps, lit: &ast::lit) {
       ast::lit_int(i, t) => {
         if i < 0_i64 {
             word(s.s,
-                 ~"-" + u64::to_str_radix(-i as u64, 10u)
+                 ~"-" + (-i as u64).to_str_radix(10u)
                  + ast_util::int_ty_to_str(t));
         } else {
             word(s.s,
-                 u64::to_str_radix(i as u64, 10u)
+                 (i as u64).to_str_radix(10u)
                  + ast_util::int_ty_to_str(t));
         }
       }
       ast::lit_uint(u, t) => {
         word(s.s,
-             u64::to_str_radix(u, 10u)
+             u.to_str_radix(10u)
              + ast_util::uint_ty_to_str(t));
       }
       ast::lit_int_unsuffixed(i) => {
         if i < 0_i64 {
-            word(s.s, ~"-" + u64::to_str_radix(-i as u64, 10u));
+            word(s.s, ~"-" + (-i as u64).to_str_radix(10u));
         } else {
-            word(s.s, u64::to_str_radix(i as u64, 10u));
+            word(s.s, (i as u64).to_str_radix(10u));
         }
       }
       ast::lit_float(f, t) => {
index 70fe6f706f79a763683fdc6556f09c765e2a86f0..22622c1cac33afa2ae24ab7f657fc9b74c69a9ed 100644 (file)
@@ -89,13 +89,11 @@ pub fn bench_str<T:MutableSet<~str>,
             let mut set = f();
             do timed(&mut self.sequential_strings) {
                 for i in range(0u, num_keys) {
-                    let s = uint::to_str(i);
-                    set.insert(s);
+                    set.insert(i.to_str());
                 }
 
                 for i in range(0u, num_keys) {
-                    let s = uint::to_str(i);
-                    assert!(set.contains(&s));
+                    assert!(set.contains(&i.to_str()));
                 }
             }
         }
@@ -104,7 +102,7 @@ pub fn bench_str<T:MutableSet<~str>,
             let mut set = f();
             do timed(&mut self.random_strings) {
                 for _ in range(0, num_keys) {
-                    let s = uint::to_str(rng.next() as uint);
+                    let s = (rng.next() as uint).to_str();
                     set.insert(s);
                 }
             }
@@ -113,11 +111,11 @@ pub fn bench_str<T:MutableSet<~str>,
         {
             let mut set = f();
             for i in range(0u, num_keys) {
-                set.insert(uint::to_str(i));
+                set.insert(i.to_str());
             }
             do timed(&mut self.delete_strings) {
                 for i in range(0u, num_keys) {
-                    assert!(set.remove(&uint::to_str(i)));
+                    assert!(set.remove(&i.to_str()));
                 }
             }
         }
index 4a32fda59d81ad5cb4e15963083b73f361b97da7..4869c486e5ea9c6b13d0f8b6ae9e145b224cdc8f 100644 (file)
@@ -24,7 +24,7 @@ fn main() {
     let n = uint::from_str(args[1]).unwrap();
 
     for i in range(0u, n) {
-        let x = uint::to_str(i);
+        let x = i.to_str();
         info!(x);
     }
 }
index 611b11560e4ae8b0e8970b3d5a16bf73d66f9366..b2491e305b254a6c3bf1d93a69228759ec9355f0 100644 (file)
@@ -125,7 +125,7 @@ fn main() {
                 let elapsed = stop - start;
 
                 out.write_line(fmt!("%d\t%d\t%s", n, fibn,
-                                    u64::to_str(elapsed)));
+                                    elapsed.to_str()));
             }
         }
     }
index 4529ebf831fdd1d173a1d4d5e53bfe87da43cb54..7dc859e559efa53a9e2868bdb141d3f7caf63669 100644 (file)
@@ -40,7 +40,7 @@ fn bind<B>(&self, f: &fn(&A) -> Option<B>) -> Option<B> {
 }
 
 fn transform(x: Option<int>) -> Option<~str> {
-    x.bind(|n| Some(*n + 1) ).bind(|n| Some(int::to_str(*n)) )
+    x.bind(|n| Some(*n + 1) ).bind(|n| Some(n.to_str()) )
 }
 
 pub fn main() {
index 8ab1bef286c0ca10dc8f0fcf29ec05af34d656ef..72bdc2ee0a63e2873ee976b879b4d44d75fc6444 100644 (file)
@@ -529,7 +529,7 @@ fn visit_bool(&self) -> bool {
     }
     fn visit_int(&self) -> bool {
         do self.get::<int>() |i| {
-            self.vals.push(int::to_str(i));
+            self.vals.push(i.to_str());
         };
         true
     }
index e2bf525df1a125ae0dcdbd7e4a70a38f6a0bb1b2..520b3583195ae75b6548e3b7f96634be6186380c 100644 (file)
@@ -32,7 +32,7 @@ trait uint_utils {
 }
 
 impl uint_utils for uint {
-    fn str(&self) -> ~str { uint::to_str(*self) }
+    fn str(&self) -> ~str { self.to_str() }
     fn multi(&self, f: &fn(uint)) {
         let mut c = 0u;
         while c < *self { f(c); c += 1u; }
index 47d9665217c2100044f0c8f2371745ea79655776..6916db28e11ea611b08b7b99aef3ed7589ce3ab8 100644 (file)
 use std::int;
 
 trait to_str {
-    fn to_str(&self) -> ~str;
+    fn to_string(&self) -> ~str;
 }
 impl to_str for int {
-    fn to_str(&self) -> ~str { int::to_str(*self) }
+    fn to_string(&self) -> ~str { self.to_str() }
 }
 impl to_str for ~str {
-    fn to_str(&self) -> ~str { self.clone() }
+    fn to_string(&self) -> ~str { self.clone() }
 }
 impl to_str for () {
-    fn to_str(&self) -> ~str { ~"()" }
+    fn to_string(&self) -> ~str { ~"()" }
 }
 
 trait map<T> {
@@ -43,7 +43,7 @@ fn foo<U, T: map<U>>(x: T) -> ~[~str] {
     x.map(|_e| ~"hi" )
 }
 fn bar<U:to_str,T:map<U>>(x: T) -> ~[~str] {
-    x.map(|_e| _e.to_str() )
+    x.map(|_e| _e.to_string() )
 }
 
 pub fn main() {
index 8982b35ff33a63ad5816874956e14045720bb099..8ecad8d4fe163e05a7db9ab15d90f59f259b17af 100644 (file)
 
 // xfail-fast
 
-#[no_std];
-
-extern mod std;
-
-use std::str::StrVector;
-use std::vec::ImmutableVector;
-use std::iterator::Iterator;
-use std::int;
-
 trait to_str {
-    fn to_str(&self) -> ~str;
+    fn to_string(&self) -> ~str;
 }
 
 impl to_str for int {
-    fn to_str(&self) -> ~str { int::to_str(*self) }
+    fn to_string(&self) -> ~str { self.to_str() }
 }
 
 impl<T:to_str> to_str for ~[T] {
-    fn to_str(&self) -> ~str {
-        fmt!("[%s]", self.iter().map(|e| e.to_str()).collect::<~[~str]>().connect(", "))
+    fn to_string(&self) -> ~str {
+        fmt!("[%s]", self.iter().map(|e| e.to_string()).collect::<~[~str]>().connect(", "))
     }
 }
 
 pub fn main() {
-    assert!(1.to_str() == ~"1");
-    assert!((~[2, 3, 4]).to_str() == ~"[2, 3, 4]");
+    assert!(1.to_string() == ~"1");
+    assert!((~[2, 3, 4]).to_string() == ~"[2, 3, 4]");
 
     fn indirect<T:to_str>(x: T) -> ~str {
-        x.to_str() + "!"
+        x.to_string() + "!"
     }
     assert!(indirect(~[10, 20]) == ~"[10, 20]!");