diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-06-08 22:04:46 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-06-09 02:22:23 +1000 |
| commit | 4b806b4d06a6b82771657f9b79728d3fba84ebed (patch) | |
| tree | 94d877c67441c10a55d343566664766ce0b82cbc /src/libextra | |
| parent | 513d2292e5a743e630ceece06255528c1902ac01 (diff) | |
| download | rust-4b806b4d06a6b82771657f9b79728d3fba84ebed.tar.gz rust-4b806b4d06a6b82771657f9b79728d3fba84ebed.zip | |
std: remove each_char* fns and methods from str, replaced by iterators.
Diffstat (limited to 'src/libextra')
| -rw-r--r-- | src/libextra/fileinput.rs | 3 | ||||
| -rw-r--r-- | src/libextra/json.rs | 6 | ||||
| -rw-r--r-- | src/libextra/net_url.rs | 7 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/libextra/fileinput.rs b/src/libextra/fileinput.rs index 3afa9b51c59..16082732715 100644 --- a/src/libextra/fileinput.rs +++ b/src/libextra/fileinput.rs @@ -414,6 +414,7 @@ mod test { use super::{FileInput, pathify, input_vec, input_vec_state}; + use core::iterator::IteratorUtil; use core::io; use core::str; use core::uint; @@ -455,7 +456,7 @@ mod test { let fi = FileInput::from_vec(copy filenames); - for "012".each_chari |line, c| { + for "012".iter().enumerate().advance |(line, c)| { assert_eq!(fi.read_byte(), c as int); assert_eq!(fi.state().line_num, line); assert_eq!(fi.state().line_num_file, 0); diff --git a/src/libextra/json.rs b/src/libextra/json.rs index 22abe0edbb9..fc1597ffed4 100644 --- a/src/libextra/json.rs +++ b/src/libextra/json.rs @@ -18,6 +18,7 @@ use core::prelude::*; +use core::iterator::IteratorUtil; use core::char; use core::float; use core::hashmap::HashMap; @@ -58,7 +59,7 @@ pub struct Error { fn escape_str(s: &str) -> ~str { let mut escaped = ~"\""; - for str::each_char(s) |c| { + for s.iter().advance |c| { match c { '"' => escaped += "\\\"", '\\' => escaped += "\\\\", @@ -913,7 +914,8 @@ impl serialize::Decoder for Decoder { fn read_char(&mut self) -> char { let mut v = ~[]; - for str::each_char(self.read_str()) |c| { v.push(c) } + let s = self.read_str(); + for s.iter().advance |c| { v.push(c) } if v.len() != 1 { fail!("string must have one character") } v[0] } diff --git a/src/libextra/net_url.rs b/src/libextra/net_url.rs index 08540775864..f26019d9282 100644 --- a/src/libextra/net_url.rs +++ b/src/libextra/net_url.rs @@ -14,6 +14,7 @@ use core::prelude::*; +use core::iterator::IteratorUtil; use core::cmp::Eq; use core::io::{Reader, ReaderUtil}; use core::io; @@ -358,7 +359,7 @@ pub fn query_to_str(query: &Query) -> ~str { // returns the scheme and the rest of the url, or a parsing error pub fn get_scheme(rawurl: &str) -> Result<(~str, ~str), ~str> { - for str::each_chari(rawurl) |i,c| { + for rawurl.iter().enumerate().advance |(i,c)| { match c { 'A' .. 'Z' | 'a' .. 'z' => loop, '0' .. '9' | '+' | '-' | '.' => { @@ -418,7 +419,7 @@ fn get_authority(rawurl: &str) -> let mut colon_count = 0; let mut (pos, begin, end) = (0, 2, len); - for str::each_chari(rawurl) |i,c| { + for rawurl.iter().enumerate().advance |(i,c)| { if i < 2 { loop; } // ignore the leading // // deal with input class first @@ -562,7 +563,7 @@ fn get_path(rawurl: &str, authority: bool) -> Result<(~str, ~str), ~str> { let len = str::len(rawurl); let mut end = len; - for str::each_chari(rawurl) |i,c| { + for rawurl.iter().enumerate().advance |(i,c)| { match c { 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '&' |'\'' | '(' | ')' | '.' | '@' | ':' | '%' | '/' | '+' | '!' | '*' | ',' | ';' | '=' |
