Skip to content

Commit ec5a028

Browse files
committed
std: convert str::char_at* to methods.
1 parent f632f46 commit ec5a028

File tree

9 files changed

+146
-152
lines changed

9 files changed

+146
-152
lines changed

src/compiletest/runtest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ fn scan_char(haystack: &str, needle: char, idx: &mut uint) -> bool {
429429
if *idx >= haystack.len() {
430430
return false;
431431
}
432-
let range = str::char_range_at(haystack, *idx);
432+
let range = haystack.char_range_at(*idx);
433433
if range.ch != needle {
434434
return false;
435435
}
@@ -440,7 +440,7 @@ fn scan_char(haystack: &str, needle: char, idx: &mut uint) -> bool {
440440
fn scan_integer(haystack: &str, idx: &mut uint) -> bool {
441441
let mut i = *idx;
442442
while i < haystack.len() {
443-
let range = str::char_range_at(haystack, i);
443+
let range = haystack.char_range_at(i);
444444
if range.ch < '0' || '9' < range.ch {
445445
break;
446446
}
@@ -460,7 +460,7 @@ fn scan_string(haystack: &str, needle: &str, idx: &mut uint) -> bool {
460460
if haystack_i >= haystack.len() {
461461
return false;
462462
}
463-
let range = str::char_range_at(haystack, haystack_i);
463+
let range = haystack.char_range_at(haystack_i);
464464
haystack_i = range.next;
465465
if !scan_char(needle, range.ch, &mut needle_i) {
466466
return false;

src/libextra/getopts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub struct Opt {
112112

113113
fn mkname(nm: &str) -> Name {
114114
if nm.len() == 1u {
115-
Short(str::char_at(nm, 0u))
115+
Short(nm.char_at(0u))
116116
} else {
117117
Long(nm.to_owned())
118118
}
@@ -261,7 +261,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
261261
let mut last_valid_opt_id = None;
262262
names = ~[];
263263
while j < curlen {
264-
let range = str::char_range_at(cur, j);
264+
let range = cur.char_range_at(j);
265265
let opt = Short(range.ch);
266266
267267
/* In a series of potential options (eg. -aheJ), if we
@@ -565,11 +565,11 @@ pub mod groups {
565565
hasarg: hasarg,
566566
occur: occur}],
567567

568-
(1,0) => ~[Opt {name: Short(str::char_at(short_name, 0)),
568+
(1,0) => ~[Opt {name: Short(short_name.char_at(0)),
569569
hasarg: hasarg,
570570
occur: occur}],
571571

572-
(1,_) => ~[Opt {name: Short(str::char_at(short_name, 0)),
572+
(1,_) => ~[Opt {name: Short(short_name.char_at(0)),
573573
hasarg: hasarg,
574574
occur: occur},
575575
Opt {name: Long((long_name)),

src/libextra/rope.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ pub mod node {
11321132
pub fn char_at(mut node: @Node, mut pos: uint) -> char {
11331133
loop {
11341134
match *node {
1135-
Leaf(x) => return str::char_at(*x.content, pos),
1135+
Leaf(x) => return x.content.char_at(pos),
11361136
Concat(Concat {left, right, _}) => {
11371137
let left_len = char_len(left);
11381138
node = if left_len > pos { left }
@@ -1257,8 +1257,7 @@ pub mod node {
12571257
return None
12581258
} else {
12591259
let range =
1260-
str::char_range_at(*aleaf.content,
1261-
(*it).leaf_byte_pos + aleaf.byte_offset);
1260+
aleaf.content.char_range_at((*it).leaf_byte_pos + aleaf.byte_offset);
12621261
let ch = range.ch;
12631262
let next = range.next;
12641263
(*it).leaf_byte_pos = next - aleaf.byte_offset;
@@ -1345,7 +1344,7 @@ mod tests {
13451344
equal = false;
13461345
} break; }
13471346
Some(c) => {
1348-
let range = str::char_range_at(*sample, string_iter);
1347+
let range = sample.char_range_at(string_iter);
13491348
string_iter = range.next;
13501349
if range.ch != c { equal = false; break; }
13511350
}

src/libextra/time.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
296296

297297
let mut i = 0u;
298298
while i < digits {
299-
let range = str::char_range_at(ss, pos);
299+
let range = ss.char_range_at(pos);
300300
pos = range.next;
301301

302302
match range.ch {
@@ -323,7 +323,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
323323
}
324324

325325
fn parse_char(s: &str, pos: uint, c: char) -> Result<uint, ~str> {
326-
let range = str::char_range_at(s, pos);
326+
let range = s.char_range_at(pos);
327327

328328
if c == range.ch {
329329
Ok(range.next)
@@ -600,7 +600,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
600600
let mut pos = pos;
601601
let len = s.len();
602602
while pos < len {
603-
let range = str::char_range_at(s, pos);
603+
let range = s.char_range_at(pos);
604604
pos = range.next;
605605
if range.ch == ' ' { break; }
606606
}
@@ -609,7 +609,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
609609
}
610610
}
611611
'z' => {
612-
let range = str::char_range_at(s, pos);
612+
let range = s.char_range_at(pos);
613613

614614
if range.ch == '+' || range.ch == '-' {
615615
match match_digits(s, range.next, 4u, false) {
@@ -655,7 +655,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
655655
let mut result = Err(~"Invalid time");
656656

657657
while !rdr.eof() && pos < len {
658-
let range = str::char_range_at(s, pos);
658+
let range = s.char_range_at(pos);
659659
let ch = range.ch;
660660
let next = range.next;
661661

src/librustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ fn check_item_non_camel_case_types(cx: &Context, it: @ast::item) {
842842
let ident = cx.sess.str_of(ident);
843843
assert!(!ident.is_empty());
844844
let ident = ident.trim_chars(&['_']);
845-
char::is_uppercase(str::char_at(ident, 0)) &&
845+
char::is_uppercase(ident.char_at(0)) &&
846846
!ident.contains_char('_')
847847
}
848848

src/libstd/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ impl<T:Reader> ReaderUtil for T {
672672
val <<= 6;
673673
val += (next & 63) as uint;
674674
}
675-
// See str::char_at
675+
// See str::StrSlice::char_at
676676
val += ((b0 << ((w + 1) as u8)) as uint)
677677
<< (w - 1) * 6 - w - 1u;
678678
chars.push(val as char);

0 commit comments

Comments
 (0)