rm obsolete integer to_str{,_radix} free functions
This commit is contained in:
parent
0d72f604b7
commit
46fc549fa9
27 changed files with 104 additions and 152 deletions
|
|
@ -89,13 +89,11 @@ impl Results {
|
|||
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 @@ impl Results {
|
|||
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 @@ impl Results {
|
|||
{
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ impl<A> option_monad<A> for Option<A> {
|
|||
}
|
||||
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -529,7 +529,7 @@ impl TyVisitor for my_visitor {
|
|||
}
|
||||
fn visit_int(&self) -> bool {
|
||||
do self.get::<int>() |i| {
|
||||
self.vals.push(int::to_str(i));
|
||||
self.vals.push(i.to_str());
|
||||
};
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@
|
|||
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() {
|
||||
|
|
|
|||
|
|
@ -10,35 +10,26 @@
|
|||
|
||||
// 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]!");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue