Skip to content

Commit ebefe42

Browse files
committed
std: remove str::to_chars
1 parent 8c59d92 commit ebefe42

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/librustpkg/version.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ fn try_parsing_version(s: &str) -> Option<Version> {
143143
let s = s.trim();
144144
debug!("Attempting to parse: %s", s);
145145
let mut parse_state = Start;
146-
// I gave up on using external iterators (tjc)
147-
for str::to_chars(s).each() |&c| {
146+
for s.iter().advance |&c| {
148147
if char::is_digit(c) {
149148
parse_state = SawDigit;
150149
}
@@ -172,7 +171,7 @@ fn is_url_like(p: &RemotePath) -> bool {
172171
/// Otherwise, return None.
173172
pub fn split_version<'a>(s: &'a str) -> Option<(&'a str, Version)> {
174173
// reject strings with multiple '#'s
175-
if { let mut i: uint = 0; for str::to_chars(s).each |&c| { if c == '#' { i += 1; } }; i > 1 } {
174+
if s.splitn_iter('#', 2).count() > 1 {
176175
return None;
177176
}
178177
match s.rfind('#') {

src/libstd/str.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,6 @@ pub fn byte_slice_no_callback<'a>(s: &'a str) -> &'a [u8] {
432432
}
433433
}
434434

435-
/// Convert a string to a unique vector of characters
436-
pub fn to_chars(s: &str) -> ~[char] {
437-
s.iter().collect()
438-
}
439-
440435
/**
441436
* Take a substring of another.
442437
*

src/test/run-pass/utf8_chars.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@
1010

1111
extern mod extra;
1212

13+
use std::iterator::IteratorUtil;
1314
use std::str;
1415
use std::vec;
1516

1617
pub fn main() {
1718
// Chars of 1, 2, 3, and 4 bytes
1819
let chs: ~[char] = ~['e', 'é', '€', 0x10000 as char];
1920
let s: ~str = str::from_chars(chs);
21+
let schs: ~[char] = s.iter().collect();
2022

2123
assert!(s.len() == 10u);
2224
assert!(str::char_len(s) == 4u);
23-
assert!(str::to_chars(s).len() == 4u);
24-
assert!(str::from_chars(str::to_chars(s)) == s);
25+
assert!(schs.len() == 4u);
26+
assert!(str::from_chars(schs) == s);
2527
assert!(s.char_at(0u) == 'e');
2628
assert!(s.char_at(1u) == 'é');
2729

0 commit comments

Comments
 (0)