Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removed unneccessary _iter suffixes from various APIs
  • Loading branch information
Kimundi committed Nov 26, 2013
1 parent b42c438 commit 24b316a
Show file tree
Hide file tree
Showing 63 changed files with 473 additions and 469 deletions.
14 changes: 7 additions & 7 deletions doc/tutorial-conditions.md
Expand Up @@ -82,7 +82,7 @@ fn read_int_pairs() -> ~[(int,int)] {
let line = fi.read_line();
// 2. Split the line into fields ("words").
let fields = line.word_iter().to_owned_vec();
let fields = line.words().to_owned_vec();
// 3. Match the vector of fields against a vector pattern.
match fields {
Expand Down Expand Up @@ -295,7 +295,7 @@ fn read_int_pairs() -> ~[(int,int)] {
let fi = FileInput::from_args();
while ! fi.eof() {
let line = fi.read_line();
let fields = line.word_iter().to_owned_vec();
let fields = line.words().to_owned_vec();
match fields {
[a, b] => pairs.push((from_str::<int>(a).unwrap(),
from_str::<int>(b).unwrap())),
Expand Down Expand Up @@ -396,7 +396,7 @@ fn read_int_pairs() -> ~[(int,int)] {
let fi = FileInput::from_args();
while ! fi.eof() {
let line = fi.read_line();
let fields = line.word_iter().to_owned_vec();
let fields = line.words().to_owned_vec();
match fields {
[a, b] => pairs.push((from_str::<int>(a).unwrap(),
from_str::<int>(b).unwrap())),
Expand Down Expand Up @@ -473,7 +473,7 @@ fn read_int_pairs() -> ~[(int,int)] {
let fi = FileInput::from_args();
while ! fi.eof() {
let line = fi.read_line();
let fields = line.word_iter().to_owned_vec();
let fields = line.words().to_owned_vec();
match fields {
[a, b] => pairs.push((from_str::<int>(a).unwrap(),
from_str::<int>(b).unwrap())),
Expand Down Expand Up @@ -551,7 +551,7 @@ fn read_int_pairs() -> ~[(int,int)] {
let fi = FileInput::from_args();
while ! fi.eof() {
let line = fi.read_line();
let fields = line.word_iter().to_owned_vec();
let fields = line.words().to_owned_vec();
match fields {
[a, b] => pairs.push((from_str::<int>(a).unwrap(),
from_str::<int>(b).unwrap())),
Expand Down Expand Up @@ -647,7 +647,7 @@ fn read_int_pairs() -> ~[(int,int)] {
let fi = FileInput::from_args();
while ! fi.eof() {
let line = fi.read_line();
let fields = line.word_iter().to_owned_vec();
let fields = line.words().to_owned_vec();
match fields {
[a, b] => pairs.push((from_str::<int>(a).unwrap(),
from_str::<int>(b).unwrap())),
Expand Down Expand Up @@ -787,7 +787,7 @@ fn read_int_pairs() -> ~[(int,int)] {
let fi = FileInput::from_args();
while ! fi.eof() {
let line = fi.read_line();
let fields = line.word_iter().to_owned_vec();
let fields = line.words().to_owned_vec();
match fields {
// Delegate parsing ints to helper function that will
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/header.rs
Expand Up @@ -145,7 +145,7 @@ fn parse_check_line(line: &str) -> Option<~str> {
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
do parse_name_value_directive(line, ~"exec-env").map |nv| {
// nv is either FOO or FOO=BAR
let mut strs: ~[~str] = nv.splitn_iter('=', 1).map(|s| s.to_owned()).collect();
let mut strs: ~[~str] = nv.splitn('=', 1).map(|s| s.to_owned()).collect();

match strs.len() {
1u => (strs.pop(), ~""),
Expand Down
18 changes: 9 additions & 9 deletions src/compiletest/runtest.rs
Expand Up @@ -383,11 +383,11 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
if num_check_lines > 0 {
// Allow check lines to leave parts unspecified (e.g., uninitialized
// bits in the wrong case of an enum) with the notation "[...]".
let check_fragments: ~[~[&str]] = check_lines.map(|s| s.split_str_iter("[...]").collect());
let check_fragments: ~[~[&str]] = check_lines.map(|s| s.split_str("[...]").collect());
// check if each line in props.check_lines appears in the
// output (in order)
let mut i = 0u;
for line in ProcRes.stdout.line_iter() {
for line in ProcRes.stdout.lines() {
let mut rest = line.trim();
let mut first = true;
let mut failed = false;
Expand Down Expand Up @@ -439,7 +439,7 @@ fn check_error_patterns(props: &TestProps,
let mut next_err_idx = 0u;
let mut next_err_pat = &props.error_patterns[next_err_idx];
let mut done = false;
for line in ProcRes.stderr.line_iter() {
for line in ProcRes.stderr.lines() {
if line.contains(*next_err_pat) {
debug!("found error pattern {}", *next_err_pat);
next_err_idx += 1u;
Expand Down Expand Up @@ -483,7 +483,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
}).collect::<~[~str]>();

fn to_lower( s : &str ) -> ~str {
let i = s.iter();
let i = s.chars();
let c : ~[char] = i.map( |c| {
if c.is_ascii() {
c.to_ascii().to_lower().to_char()
Expand Down Expand Up @@ -512,7 +512,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
// filename:line1:col1: line2:col2: *warning:* msg
// where line1:col1: is the starting point, line2:col2:
// is the ending point, and * represents ANSI color codes.
for line in ProcRes.stderr.line_iter() {
for line in ProcRes.stderr.lines() {
let mut was_expected = false;
for (i, ee) in expected_errors.iter().enumerate() {
if !found_flags[i] {
Expand Down Expand Up @@ -777,7 +777,7 @@ fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
fn split_maybe_args(argstr: &Option<~str>) -> ~[~str] {
match *argstr {
Some(ref s) => {
s.split_iter(' ')
s.split(' ')
.filter_map(|s| if s.is_whitespace() {None} else {Some(s.to_owned())})
.collect()
}
Expand Down Expand Up @@ -896,7 +896,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
let cmdline = make_cmdline("", args.prog, args.args);

// get bare program string
let mut tvec: ~[~str] = args.prog.split_iter('/').map(|ts| ts.to_owned()).collect();
let mut tvec: ~[~str] = args.prog.split('/').map(|ts| ts.to_owned()).collect();
let prog_short = tvec.pop();

// copy to target
Expand Down Expand Up @@ -939,7 +939,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
Some(~""));

let mut exitcode : int = 0;
for c in exitcode_out.iter() {
for c in exitcode_out.chars() {
if !c.is_digit() { break; }
exitcode = exitcode * 10 + match c {
'0' .. '9' => c as int - ('0' as int),
Expand Down Expand Up @@ -1089,7 +1089,7 @@ fn disassemble_extract(config: &config, _props: &TestProps,
fn count_extracted_lines(p: &Path) -> uint {
let x = File::open(&p.with_extension("ll")).read_to_end();
let x = str::from_utf8_owned(x);
x.line_iter().len()
x.lines().len()
}


Expand Down
2 changes: 1 addition & 1 deletion src/libextra/base64.rs
Expand Up @@ -193,7 +193,7 @@ impl<'self> FromBase64 for &'self str {
let mut buf: u32 = 0;
let mut modulus = 0;

let mut it = self.byte_iter().enumerate();
let mut it = self.bytes().enumerate();
for (idx, byte) in it {
let val = byte as u32;

Expand Down
28 changes: 14 additions & 14 deletions src/libextra/bitv.rs
Expand Up @@ -413,7 +413,7 @@ impl Bitv {
}

#[inline]
pub fn rev_liter<'a>(&'a self) -> Invert<BitvIterator<'a>> {
pub fn rev_iter<'a>(&'a self) -> Invert<BitvIterator<'a>> {
self.iter().invert()
}

Expand Down Expand Up @@ -723,38 +723,38 @@ impl BitvSet {
}

pub fn difference(&self, other: &BitvSet, f: |&uint| -> bool) -> bool {
for (i, w1, w2) in self.common_iter(other) {
for (i, w1, w2) in self.commons(other) {
if !iterate_bits(i, w1 & !w2, |b| f(&b)) {
return false
}
};
/* everything we have that they don't also shows up */
self.outlier_iter(other).advance(|(mine, i, w)|
self.outliers(other).advance(|(mine, i, w)|
!mine || iterate_bits(i, w, |b| f(&b))
)
}

pub fn symmetric_difference(&self, other: &BitvSet, f: |&uint| -> bool)
-> bool {
for (i, w1, w2) in self.common_iter(other) {
for (i, w1, w2) in self.commons(other) {
if !iterate_bits(i, w1 ^ w2, |b| f(&b)) {
return false
}
};
self.outlier_iter(other).advance(|(_, i, w)| iterate_bits(i, w, |b| f(&b)))
self.outliers(other).advance(|(_, i, w)| iterate_bits(i, w, |b| f(&b)))
}

pub fn intersection(&self, other: &BitvSet, f: |&uint| -> bool) -> bool {
self.common_iter(other).advance(|(i, w1, w2)| iterate_bits(i, w1 & w2, |b| f(&b)))
self.commons(other).advance(|(i, w1, w2)| iterate_bits(i, w1 & w2, |b| f(&b)))
}

pub fn union(&self, other: &BitvSet, f: |&uint| -> bool) -> bool {
for (i, w1, w2) in self.common_iter(other) {
for (i, w1, w2) in self.commons(other) {
if !iterate_bits(i, w1 | w2, |b| f(&b)) {
return false
}
};
self.outlier_iter(other).advance(|(_, i, w)| iterate_bits(i, w, |b| f(&b)))
self.outliers(other).advance(|(_, i, w)| iterate_bits(i, w, |b| f(&b)))
}
}

Expand All @@ -763,12 +763,12 @@ impl cmp::Eq for BitvSet {
if self.size != other.size {
return false;
}
for (_, w1, w2) in self.common_iter(other) {
for (_, w1, w2) in self.commons(other) {
if w1 != w2 {
return false;
}
}
for (_, _, w) in self.outlier_iter(other) {
for (_, _, w) in self.outliers(other) {
if w != 0 {
return false;
}
Expand Down Expand Up @@ -803,15 +803,15 @@ impl Set<uint> for BitvSet {
}

fn is_subset(&self, other: &BitvSet) -> bool {
for (_, w1, w2) in self.common_iter(other) {
for (_, w1, w2) in self.commons(other) {
if w1 & w2 != w1 {
return false;
}
}
/* If anything is not ours, then everything is not ours so we're
definitely a subset in that case. Otherwise if there's any stray
ones that 'other' doesn't have, we're not a subset. */
for (mine, _, w) in self.outlier_iter(other) {
for (mine, _, w) in self.outliers(other) {
if !mine {
return true;
} else if w != 0 {
Expand Down Expand Up @@ -865,7 +865,7 @@ impl BitvSet {
/// both have in common. The three yielded arguments are (bit location,
/// w1, w2) where the bit location is the number of bits offset so far,
/// and w1/w2 are the words coming from the two vectors self, other.
fn common_iter<'a>(&'a self, other: &'a BitvSet)
fn commons<'a>(&'a self, other: &'a BitvSet)
-> Map<'static, ((uint, &'a uint), &'a ~[uint]), (uint, uint, uint),
Zip<Enumerate<vec::VecIterator<'a, uint>>, Repeat<&'a ~[uint]>>> {
let min = num::min(self.bitv.storage.len(), other.bitv.storage.len());
Expand All @@ -881,7 +881,7 @@ impl BitvSet {
/// The yielded arguments are a `bool`, the bit offset, and a word. The `bool`
/// is true if the word comes from `self`, and `false` if it comes from
/// `other`.
fn outlier_iter<'a>(&'a self, other: &'a BitvSet)
fn outliers<'a>(&'a self, other: &'a BitvSet)
-> Map<'static, ((uint, &'a uint), uint), (bool, uint, uint),
Zip<Enumerate<vec::VecIterator<'a, uint>>, Repeat<uint>>> {
let slen = self.bitv.storage.len();
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/getopts.rs
Expand Up @@ -413,7 +413,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
let mut i_arg = None;
if cur[1] == '-' as u8 {
let tail = cur.slice(2, curlen);
let tail_eq: ~[&str] = tail.split_iter('=').collect();
let tail_eq: ~[&str] = tail.split('=').collect();
if tail_eq.len() <= 1 {
names = ~[Long(tail.to_owned())];
} else {
Expand Down Expand Up @@ -735,7 +735,7 @@ pub mod groups {

// Normalize desc to contain words separated by one space character
let mut desc_normalized_whitespace = ~"";
for word in desc.word_iter() {
for word in desc.words() {
desc_normalized_whitespace.push_str(word);
desc_normalized_whitespace.push_char(' ');
}
Expand Down Expand Up @@ -826,7 +826,7 @@ pub mod groups {
cont
};

ss.char_offset_iter().advance(|x| machine(x));
ss.char_indices().advance(|x| machine(x));

// Let the automaton 'run out' by supplying trailing whitespace
while cont && match state { B | C => true, A => false } {
Expand Down
10 changes: 5 additions & 5 deletions src/libextra/glob.rs
Expand Up @@ -102,7 +102,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> GlobIterator {

let root_len = pat_root.map_default(0u, |p| p.as_vec().len());
let dir_patterns = pattern.slice_from(root_len.min(&pattern.len()))
.split_terminator_iter(is_sep).map(|s| Pattern::new(s)).to_owned_vec();
.split_terminator(is_sep).map(|s| Pattern::new(s)).to_owned_vec();

let todo = list_dir_sorted(&root).move_iter().map(|x|(x,0u)).to_owned_vec();

Expand Down Expand Up @@ -209,7 +209,7 @@ impl Pattern {
*/
pub fn new(pattern: &str) -> Pattern {

let chars = pattern.iter().to_owned_vec();
let chars = pattern.chars().to_owned_vec();
let mut tokens = ~[];
let mut i = 0;

Expand Down Expand Up @@ -272,7 +272,7 @@ impl Pattern {
*/
pub fn escape(s: &str) -> ~str {
let mut escaped = ~"";
for c in s.iter() {
for c in s.chars() {
match c {
// note that ! does not need escaping because it is only special inside brackets
'?' | '*' | '[' | ']' => {
Expand Down Expand Up @@ -586,10 +586,10 @@ mod test {
let pats = ["[a-z123]", "[1a-z23]", "[123a-z]"];
for &p in pats.iter() {
let pat = Pattern::new(p);
for c in "abcdefghijklmnopqrstuvwxyz".iter() {
for c in "abcdefghijklmnopqrstuvwxyz".chars() {
assert!(pat.matches(c.to_str()));
}
for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ".iter() {
for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars() {
let options = MatchOptions {case_sensitive: false, .. MatchOptions::new()};
assert!(pat.matches_with(c.to_str(), options));
}
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/hex.rs
Expand Up @@ -91,7 +91,7 @@ impl<'self> FromHex for &'self str {
let mut modulus = 0;
let mut buf = 0u8;

for (idx, byte) in self.byte_iter().enumerate() {
for (idx, byte) in self.bytes().enumerate() {
buf <<= 4;

match byte as char {
Expand Down
10 changes: 5 additions & 5 deletions src/libextra/json.rs
Expand Up @@ -59,7 +59,7 @@ pub struct Error {

fn escape_str(s: &str) -> ~str {
let mut escaped = ~"\"";
for c in s.iter() {
for c in s.chars() {
match c {
'"' => escaped.push_str("\\\""),
'\\' => escaped.push_str("\\\\"),
Expand Down Expand Up @@ -559,7 +559,7 @@ impl<T : Iterator<char>> Parser<T> {
}

fn parse_ident(&mut self, ident: &str, value: Json) -> Result<Json, Error> {
if ident.iter().all(|c| c == self.next_char()) {
if ident.chars().all(|c| c == self.next_char()) {
self.bump();
Ok(value)
} else {
Expand Down Expand Up @@ -844,13 +844,13 @@ impl<T : Iterator<char>> Parser<T> {
/// Decodes a json value from an `&mut io::Reader`
pub fn from_reader(rdr: &mut io::Reader) -> Result<Json, Error> {
let s = str::from_utf8(rdr.read_to_end());
let mut parser = Parser(~s.iter());
let mut parser = Parser(~s.chars());
parser.parse()
}

/// Decodes a json value from a string
pub fn from_str(s: &str) -> Result<Json, Error> {
let mut parser = Parser(~s.iter());
let mut parser = Parser(~s.chars());
parser.parse()
}

Expand Down Expand Up @@ -930,7 +930,7 @@ impl serialize::Decoder for Decoder {
fn read_char(&mut self) -> char {
let s = self.read_str();
{
let mut it = s.iter();
let mut it = s.chars();
match (it.next(), it.next()) {
// exactly one character
(Some(c), None) => return c,
Expand Down

5 comments on commit 24b316a

@bors
Copy link
Contributor

@bors bors commented on 24b316a Nov 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at Kimundi@24b316a

@bors
Copy link
Contributor

@bors bors commented on 24b316a Nov 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Kimundi/rust/str_de_iter = 24b316a into auto

@bors
Copy link
Contributor

@bors bors commented on 24b316a Nov 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kimundi/rust/str_de_iter = 24b316a merged ok, testing candidate = 21990cd

@bors
Copy link
Contributor

@bors bors commented on 24b316a Nov 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 24b316a Nov 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 21990cd

Please sign in to comment.