std: remove str::{len, slice, is_empty} in favour of methods.

This commit is contained in:
Huon Wilson 2013-06-10 00:44:58 +10:00
parent b29cd22bce
commit c32fb53cf9
35 changed files with 185 additions and 207 deletions

View file

@ -81,27 +81,27 @@ fn make_random_fasta(wr: @io::Writer,
for uint::range(0u, n as uint) |_i| {
str::push_char(&mut op, select_random(myrandom_next(rng, 100u32),
copy genelist));
if str::len(op) >= LINE_LENGTH() {
if op.len() >= LINE_LENGTH() {
wr.write_line(op);
op = ~"";
}
}
if str::len(op) > 0u { wr.write_line(op); }
if op.len() > 0u { wr.write_line(op); }
}
fn make_repeat_fasta(wr: @io::Writer, id: ~str, desc: ~str, s: ~str, n: int) {
unsafe {
wr.write_line(~">" + id + " " + desc);
let mut op: ~str = ~"";
let sl: uint = str::len(s);
let sl: uint = s.len();
for uint::range(0u, n as uint) |i| {
str::raw::push_byte(&mut op, s[i % sl]);
if str::len(op) >= LINE_LENGTH() {
if op.len() >= LINE_LENGTH() {
wr.write_line(op);
op = ~"";
}
}
if str::len(op) > 0u { wr.write_line(op); }
if op.len() > 0u { wr.write_line(op); }
}
}

View file

@ -191,7 +191,7 @@ fn main() {
while !rdr.eof() {
let line: ~str = rdr.read_line();
if str::len(line) == 0u { loop; }
if line.len() == 0u { loop; }
match (line[0] as char, proc_mode) {

View file

@ -2,7 +2,7 @@ use std::str;
fn main() {
let v = ~"test";
let sslice = str::slice(v, 0, v.len());
let sslice = v.slice(0, v.len());
//~^ ERROR borrowed value does not live long enough
fail!(sslice);
}

View file

@ -20,5 +20,5 @@ fn main() {
}
fn startfn() {
assert!(str::is_empty(~"Ensure that the child task runs by failing"));
assert!("Ensure that the child task runs by failing".is_empty());
}

View file

@ -18,8 +18,8 @@ pub fn main() {
let mut i = 20;
let mut expected_len = 1u;
while i > 0 {
error!(str::len(a));
assert_eq!(str::len(a), expected_len);
error!(a.len());
assert_eq!(a.len(), expected_len);
a = a + a; // FIXME(#3387)---can't write a += a
i -= 1;
expected_len *= 2u;

View file

@ -18,7 +18,7 @@ pub fn main() {
let chs: ~[char] = ~['e', 'é', '€', 0x10000 as char];
let s: ~str = str::from_chars(chs);
assert!(str::len(s) == 10u);
assert!(s.len() == 10u);
assert!(str::char_len(s) == 4u);
assert!(str::to_chars(s).len() == 4u);
assert!(str::from_chars(str::to_chars(s)) == s);