summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorKevin Cantu <me@kevincantu.org>2012-02-21 21:04:29 -0800
committerMarijn Haverbeke <marijnh@gmail.com>2012-02-23 17:00:19 +0100
commit98447f523603ce8ca5a258f216f6fcbd90fe114f (patch)
tree0cff11ac753d9a2a71bc69bd2e1d64baf8ae4248 /src/libcore
parent7a6498668f2f4d3eff393809418b565d027b35bd (diff)
downloadrust-98447f523603ce8ca5a258f216f6fcbd90fe114f.tar.gz
rust-98447f523603ce8ca5a258f216f6fcbd90fe114f.zip
(core::str) mostly rename len -> len_chars
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/extfmt.rs6
-rw-r--r--src/libcore/str.rs34
2 files changed, 21 insertions, 19 deletions
diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs
index 30676e34de8..5fca4d69f3a 100644
--- a/src/libcore/extfmt.rs
+++ b/src/libcore/extfmt.rs
@@ -325,7 +325,7 @@ mod rt {
             alt cv.precision {
               count_implied { s }
               count_is(max) {
-                if max as uint < str::len(s) {
+                if max as uint < str::len_chars(s) {
                     str::substr(s, 0u, max as uint)
                 } else { s }
               }
@@ -368,7 +368,7 @@ mod rt {
                 ""
             } else {
                 let s = uint::to_str(num, radix);
-                let len = str::len(s);
+                let len = str::len_chars(s);
                 if len < prec {
                     let diff = prec - len;
                     let pad = str_init_elt(diff, '0');
@@ -400,7 +400,7 @@ mod rt {
             uwidth = width as uint;
           }
         }
-        let strlen = str::len(s);
+        let strlen = str::len_chars(s);
         if uwidth <= strlen { ret s; }
         let padchar = ' ';
         let diff = uwidth - strlen;
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index d81f2d45d40..de8ba2f28b6 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -86,7 +86,7 @@ export
    is_not_empty,
    is_whitespace,
    len_bytes,
-   len_chars, len,
+   len_chars, //len,
 
    // Misc
    // FIXME: perhaps some more of this section shouldn't be exported?
@@ -529,7 +529,7 @@ fn split(ss: str, sepfn: fn(cc: char)->bool) -> [str] {
         }
     });
 
-    if len(accum) >= 0u || ends_with_sep {
+    if len_chars(accum) >= 0u || ends_with_sep {
         vv += [accum];
     }
 
@@ -601,7 +601,7 @@ separated by whitespace
 */
 fn words(ss: str) -> [str] {
     ret vec::filter( split(ss, {|cc| char::is_whitespace(cc)}),
-                     {|w| 0u < str::len(w)});
+                     {|w| 0u < str::len_chars(w)});
 }
 
 /*
@@ -611,7 +611,7 @@ Create a vector of substrings of size `nn`
 */
 fn windowed(nn: uint, ss: str) -> [str] {
     let ww = [];
-    let len = str::len(ss);
+    let len = str::len_chars(ss);
 
     assert 1u <= nn;
 
@@ -883,7 +883,7 @@ fn byte_index_from(s: str, b: u8, start: uint, end: uint) -> option<uint> {
 // (as option some/none)
 fn rindex(ss: str, cc: char) -> option<uint> {
     let bii = len_bytes(ss);
-    let cii = len(ss);
+    let cii = len_chars(ss);
     while bii > 0u {
         let {ch, prev} = char_range_at_reverse(ss, bii);
         cii -= 1u;
@@ -1008,8 +1008,8 @@ haystack - The string to look in
 needle - The string to look for
 */
 fn ends_with(haystack: str, needle: str) -> bool {
-    let haystack_len: uint = len(haystack);
-    let needle_len: uint = len(needle);
+    let haystack_len: uint = len_chars(haystack);
+    let needle_len: uint = len_chars(needle);
     ret if needle_len == 0u {
             true
         } else if needle_len > haystack_len {
@@ -1079,7 +1079,9 @@ fn len(s: str) -> uint {
     substr_len_chars(s, 0u, len_bytes(s))
 }
 
-fn len_chars(s: str) -> uint { len(s) }
+fn len_chars(s: str) -> uint {
+    substr_len_chars(s, 0u, len_bytes(s))
+}
 
 /*
 Section: Misc
@@ -1529,14 +1531,14 @@ mod tests {
         assert (len_bytes("\u2620") == 3u);
         assert (len_bytes("\U0001d11e") == 4u);
 
-        assert (len("") == 0u);
-        assert (len("hello world") == 11u);
-        assert (len("\x63") == 1u);
-        assert (len("\xa2") == 1u);
-        assert (len("\u03c0") == 1u);
-        assert (len("\u2620") == 1u);
-        assert (len("\U0001d11e") == 1u);
-        assert (len("ประเทศไทย中华Việt Nam") == 19u);
+        assert (len_chars("") == 0u);
+        assert (len_chars("hello world") == 11u);
+        assert (len_chars("\x63") == 1u);
+        assert (len_chars("\xa2") == 1u);
+        assert (len_chars("\u03c0") == 1u);
+        assert (len_chars("\u2620") == 1u);
+        assert (len_chars("\U0001d11e") == 1u);
+        assert (len_chars("ประเทศไทย中华Việt Nam") == 19u);
     }
 
     #[test]