about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorKevin Cantu <me@kevincantu.org>2012-01-30 20:27:16 -0800
committerBrian Anderson <banderson@mozilla.com>2012-01-31 14:29:11 -0800
commit685a434e0a4b432125feda745e4c4d034dc74245 (patch)
tree98c67fbdadce8f60b7a579a2d05f2197ccc980dc /src/libcore
parentbe9129f556f8f43158ccac31dab50aa6b79115b6 (diff)
Rename str::loop_chars to str::all,
rename str::loop_chars_sub to str::substr_all, and
propagate this change to std::rope and rustdoc's calls to these
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/str.rs40
1 files changed, 7 insertions, 33 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 7c588b13970..c05348b67e5 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -60,7 +60,6 @@ export
    hash,
 
    // Iterating through strings
-   loop_chars,
    all,
    any,
    map,
@@ -94,7 +93,7 @@ export
    utf8_char_width,
    char_range_at,
    char_at,
-   loop_chars_sub,
+   substr_all,
    escape_char,
    as_buf,
    //buf,
@@ -741,7 +740,7 @@ Escapes special characters inside the string, making it safe for transfer.
 */
 fn escape(s: str) -> str {
     let r = "";
-    loop_chars(s, { |c| r += escape_char(c); true });
+    all(s, { |c| r += escape_char(c); true });
     r
 }
 
@@ -782,36 +781,13 @@ Section: Iterating through strings
 */
 
 /*
-Function: loop_chars
-
-Loop through a string, char by char
-
-Parameters:
-s  - A string to traverse. It may be empty.
-it - A block to execute with each consecutive character of `s`.
-Return `true` to continue, `false` to stop.
-
-Returns:
-
-`true` If execution proceeded correctly, `false` if it was interrupted,
-that is if `it` returned `false` at any point.
-
-FIXME: rename to 'chars_loop' (change? currently a synonym to 'all')
- */
-fn loop_chars(s: str, it: fn(char) -> bool) -> bool{
-    ret loop_chars_sub(s, 0u, byte_len(s), it);
-}
-
-/*
 Function: all
 
 Return true if a predicate matches all characters or
 if the string contains no characters
-
-// FIXME: a synonym to loop_chars
 */
-fn all(ss: str, ff: fn(char) -> bool) -> bool {
-    str::loop_chars(ss, ff)
+fn all(s: str, it: fn(char) -> bool) -> bool{
+    ret substr_all(s, 0u, byte_len(s), it);
 }
 
 /*
@@ -1054,7 +1030,7 @@ Function: is_whitespace
 Returns true if the string contains only whitespace
 */
 fn is_whitespace(s: str) -> bool {
-    ret loop_chars(s, char::is_whitespace);
+    ret all(s, char::is_whitespace);
 }
 
 /*
@@ -1270,7 +1246,7 @@ Pluck a character out of a string
 fn char_at(s: str, i: uint) -> char { ret char_range_at(s, i).ch; }
 
 /*
-Function: loop_chars_sub
+Function: substr_all
 
 Loop through a substring, char by char
 
@@ -1290,10 +1266,8 @@ Safety note:
 - This function does not check whether the substring is valid.
 - This function fails if `byte_offset` or `byte_len` do not
  represent valid positions inside `s`
-
-FIXME: rename to 'substr_all'
  */
-fn loop_chars_sub(s: str, byte_offset: uint, byte_len: uint,
+fn substr_all(s: str, byte_offset: uint, byte_len: uint,
               it: fn(char) -> bool) -> bool {
    let i = byte_offset;
    let result = true;