about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2013-06-11 00:49:19 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2013-06-11 00:49:19 +1000
commitebefe425b962d3914cc523d7f539fdb2244cec06 (patch)
tree0cc1f5e4804870961a6d04dcd7ea7f5b1e04042c
parent8c59d920a12fe40398a0033438ff426bb3387fd0 (diff)
downloadrust-ebefe425b962d3914cc523d7f539fdb2244cec06.tar.gz
rust-ebefe425b962d3914cc523d7f539fdb2244cec06.zip
std: remove str::to_chars
-rw-r--r--src/librustpkg/version.rs5
-rw-r--r--src/libstd/str.rs5
-rw-r--r--src/test/run-pass/utf8_chars.rs6
3 files changed, 6 insertions, 10 deletions
diff --git a/src/librustpkg/version.rs b/src/librustpkg/version.rs
index b38f440a941..434583eb79e 100644
--- a/src/librustpkg/version.rs
+++ b/src/librustpkg/version.rs
@@ -143,8 +143,7 @@ fn try_parsing_version(s: &str) -> Option<Version> {
     let s = s.trim();
     debug!("Attempting to parse: %s", s);
     let mut parse_state = Start;
-    // I gave up on using external iterators (tjc)
-    for str::to_chars(s).each() |&c| {
+    for s.iter().advance |&c| {
         if char::is_digit(c) {
             parse_state = SawDigit;
         }
@@ -172,7 +171,7 @@ fn is_url_like(p: &RemotePath) -> bool {
 /// Otherwise, return None.
 pub fn split_version<'a>(s: &'a str) -> Option<(&'a str, Version)> {
     // reject strings with multiple '#'s
-    if { let mut i: uint = 0; for str::to_chars(s).each |&c| { if c == '#' { i += 1; } }; i > 1 } {
+    if s.splitn_iter('#', 2).count() > 1 {
         return None;
     }
     match s.rfind('#') {
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index a7fe102738d..8967b447fd7 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -432,11 +432,6 @@ pub fn byte_slice_no_callback<'a>(s: &'a str) -> &'a [u8] {
     }
 }
 
-/// Convert a string to a unique vector of characters
-pub fn to_chars(s: &str) -> ~[char] {
-    s.iter().collect()
-}
-
 /**
  * Take a substring of another.
  *
diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs
index b7ce617fe50..d3bfd9b0164 100644
--- a/src/test/run-pass/utf8_chars.rs
+++ b/src/test/run-pass/utf8_chars.rs
@@ -10,6 +10,7 @@
 
 extern mod extra;
 
+use std::iterator::IteratorUtil;
 use std::str;
 use std::vec;
 
@@ -17,11 +18,12 @@ pub fn main() {
     // Chars of 1, 2, 3, and 4 bytes
     let chs: ~[char] = ~['e', 'é', '€', 0x10000 as char];
     let s: ~str = str::from_chars(chs);
+    let schs: ~[char] = s.iter().collect();
 
     assert!(s.len() == 10u);
     assert!(str::char_len(s) == 4u);
-    assert!(str::to_chars(s).len() == 4u);
-    assert!(str::from_chars(str::to_chars(s)) == s);
+    assert!(schs.len() == 4u);
+    assert!(str::from_chars(schs) == s);
     assert!(s.char_at(0u) == 'e');
     assert!(s.char_at(1u) == 'é');