1
Fork 0

std: remove each_char* fns and methods from str, replaced by iterators.

This commit is contained in:
Huon Wilson 2013-06-08 22:04:46 +10:00
parent 513d2292e5
commit 4b806b4d06
10 changed files with 80 additions and 149 deletions

View file

@ -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]
}