Skip to content

Commit 5790b79

Browse files
killerswanbrson
authored andcommitted
---
yaml --- r: 13933 b: refs/heads/try c: 685a434 h: refs/heads/master i: 13931: 6bf53aa v: v3
1 parent 0c0c156 commit 5790b79

File tree

4 files changed

+12
-38
lines changed

4 files changed

+12
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: be9129f556f8f43158ccac31dab50aa6b79115b6
5+
refs/heads/try: 685a434e0a4b432125feda745e4c4d034dc74245
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/libcore/str.rs

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export
6060
hash,
6161

6262
// Iterating through strings
63-
loop_chars,
6463
all,
6564
any,
6665
map,
@@ -94,7 +93,7 @@ export
9493
utf8_char_width,
9594
char_range_at,
9695
char_at,
97-
loop_chars_sub,
96+
substr_all,
9897
escape_char,
9998
as_buf,
10099
//buf,
@@ -741,7 +740,7 @@ Escapes special characters inside the string, making it safe for transfer.
741740
*/
742741
fn escape(s: str) -> str {
743742
let r = "";
744-
loop_chars(s, { |c| r += escape_char(c); true });
743+
all(s, { |c| r += escape_char(c); true });
745744
r
746745
}
747746

@@ -781,37 +780,14 @@ fn hash(&&s: str) -> uint {
781780
Section: Iterating through strings
782781
*/
783782

784-
/*
785-
Function: loop_chars
786-
787-
Loop through a string, char by char
788-
789-
Parameters:
790-
s - A string to traverse. It may be empty.
791-
it - A block to execute with each consecutive character of `s`.
792-
Return `true` to continue, `false` to stop.
793-
794-
Returns:
795-
796-
`true` If execution proceeded correctly, `false` if it was interrupted,
797-
that is if `it` returned `false` at any point.
798-
799-
FIXME: rename to 'chars_loop' (change? currently a synonym to 'all')
800-
*/
801-
fn loop_chars(s: str, it: fn(char) -> bool) -> bool{
802-
ret loop_chars_sub(s, 0u, byte_len(s), it);
803-
}
804-
805783
/*
806784
Function: all
807785
808786
Return true if a predicate matches all characters or
809787
if the string contains no characters
810-
811-
// FIXME: a synonym to loop_chars
812788
*/
813-
fn all(ss: str, ff: fn(char) -> bool) -> bool {
814-
str::loop_chars(ss, ff)
789+
fn all(s: str, it: fn(char) -> bool) -> bool{
790+
ret substr_all(s, 0u, byte_len(s), it);
815791
}
816792

817793
/*
@@ -1054,7 +1030,7 @@ Function: is_whitespace
10541030
Returns true if the string contains only whitespace
10551031
*/
10561032
fn is_whitespace(s: str) -> bool {
1057-
ret loop_chars(s, char::is_whitespace);
1033+
ret all(s, char::is_whitespace);
10581034
}
10591035

10601036
/*
@@ -1270,7 +1246,7 @@ Pluck a character out of a string
12701246
fn char_at(s: str, i: uint) -> char { ret char_range_at(s, i).ch; }
12711247

12721248
/*
1273-
Function: loop_chars_sub
1249+
Function: substr_all
12741250
12751251
Loop through a substring, char by char
12761252
@@ -1290,10 +1266,8 @@ Safety note:
12901266
- This function does not check whether the substring is valid.
12911267
- This function fails if `byte_offset` or `byte_len` do not
12921268
represent valid positions inside `s`
1293-
1294-
FIXME: rename to 'substr_all'
12951269
*/
1296-
fn loop_chars_sub(s: str, byte_offset: uint, byte_len: uint,
1270+
fn substr_all(s: str, byte_offset: uint, byte_len: uint,
12971271
it: fn(char) -> bool) -> bool {
12981272
let i = byte_offset;
12991273
let result = true;

branches/try/src/libstd/rope.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ mod node {
11371137

11381138
fn loop_chars(node: @node, it: fn(char) -> bool) -> bool {
11391139
ret loop_leaves(node, {|leaf|
1140-
ret str::loop_chars_sub(*leaf.content,
1140+
ret str::substr_all(*leaf.content,
11411141
leaf.byte_offset,
11421142
leaf.byte_len, it)
11431143
})
@@ -1494,4 +1494,4 @@ mod tests {
14941494

14951495
assert eq(r, r2);
14961496
}
1497-
}
1497+
}

branches/try/src/rustdoc/unindent_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn unindent(s: str) -> str {
4747
} else {
4848
saw_first_line = true;
4949
let spaces = 0u;
50-
str::loop_chars(line) {|char|
50+
str::all(line) {|char|
5151
// Only comparing against space because I wouldn't
5252
// know what to do with mixed whitespace chars
5353
if char == ' ' {
@@ -117,4 +117,4 @@ fn should_not_ignore_first_line_indent_in_a_single_line_para() {
117117
let s = "line1\n\n line2";
118118
let r = unindent(s);
119119
assert r == "line1\n\n line2";
120-
}
120+
}

0 commit comments

Comments
 (0)