about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
Diffstat (limited to 'src/libextra')
-rw-r--r--src/libextra/dlist.rs3
-rw-r--r--src/libextra/fileinput.rs3
-rw-r--r--src/libextra/flate.rs3
-rw-r--r--src/libextra/flatpipes.rs1
-rw-r--r--src/libextra/json.rs6
-rw-r--r--src/libextra/list.rs4
-rw-r--r--src/libextra/net_url.rs7
-rw-r--r--src/libextra/num/bigint.rs15
-rw-r--r--src/libextra/par.rs18
-rw-r--r--src/libextra/sort.rs3
-rw-r--r--src/libextra/stats.rs7
-rw-r--r--src/libextra/std.rc1
-rw-r--r--src/libextra/sync.rs1
-rw-r--r--src/libextra/tempfile.rs1
-rw-r--r--src/libextra/time.rs3
-rw-r--r--src/libextra/treemap.rs2
-rw-r--r--src/libextra/uv_ll.rs1
17 files changed, 36 insertions, 43 deletions
diff --git a/src/libextra/dlist.rs b/src/libextra/dlist.rs
index 52e2b75d6b6..7fac125243e 100644
--- a/src/libextra/dlist.rs
+++ b/src/libextra/dlist.rs
@@ -20,6 +20,7 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
 
 use core::prelude::*;
 
+use core::iterator::IteratorUtil;
 use core::managed;
 use core::old_iter;
 use core::vec;
@@ -110,7 +111,7 @@ pub fn from_elem<T>(data: T) -> @mut DList<T> {
 
 /// Creates a new dlist from a vector of elements, maintaining the same order
 pub fn from_vec<T:Copy>(vec: &[T]) -> @mut DList<T> {
-    do vec::foldl(DList(), vec) |list,data| {
+    do vec.iter().fold(DList()) |list,data| {
         list.push(*data); // Iterating left-to-right -- add newly to the tail.
         list
     }
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/flate.rs b/src/libextra/flate.rs
index 076126e0432..0fde03b69cb 100644
--- a/src/libextra/flate.rs
+++ b/src/libextra/flate.rs
@@ -16,8 +16,6 @@ Simple compression
 
 #[allow(missing_doc)];
 
-use core::prelude::*;
-
 use core::libc::{c_void, size_t, c_int};
 use core::libc;
 use core::vec;
@@ -87,6 +85,7 @@ mod tests {
     use super::*;
     use core::rand;
     use core::rand::RngUtil;
+    use core::prelude::*;
 
     #[test]
     #[allow(non_implicitly_copyable_typarams)]
diff --git a/src/libextra/flatpipes.rs b/src/libextra/flatpipes.rs
index e8239b9f7fd..c0f619c1b85 100644
--- a/src/libextra/flatpipes.rs
+++ b/src/libextra/flatpipes.rs
@@ -654,7 +654,6 @@ mod test {
     use core::int;
     use core::io::BytesWriter;
     use core::result;
-    use core::sys;
     use core::task;
 
     #[test]
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/list.rs b/src/libextra/list.rs
index 7a38be8944f..0d0b5ea00f0 100644
--- a/src/libextra/list.rs
+++ b/src/libextra/list.rs
@@ -12,7 +12,7 @@
 
 use core::prelude::*;
 
-use core::vec;
+use core::iterator::IteratorUtil;
 
 #[deriving(Eq)]
 pub enum List<T> {
@@ -28,7 +28,7 @@ pub enum MutList<T> {
 
 /// Create a list from a vector
 pub fn from_vec<T:Copy>(v: &[T]) -> @List<T> {
-    vec::foldr(v, @Nil::<T>, |h, t| @Cons(*h, t))
+    v.rev_iter().fold(@Nil::<T>, |t, h| @Cons(*h, t))
 }
 
 /**
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' | '&' |'\'' | '(' | ')' | '.'
           | '@' | ':' | '%' | '/' | '+' | '!' | '*' | ',' | ';' | '='
diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs
index 77eef1d67ef..1411079d52f 100644
--- a/src/libextra/num/bigint.rs
+++ b/src/libextra/num/bigint.rs
@@ -19,7 +19,7 @@ A BigInt is a combination of BigUint and Sign.
 #[allow(missing_doc)];
 
 use core::prelude::*;
-
+use core::iterator::IteratorUtil;
 use core::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
 use core::int;
 use core::num::{IntConvertible, Zero, One, ToStrRadix, FromStrRadix, Orderable};
@@ -129,12 +129,9 @@ impl TotalOrd for BigUint {
         if s_len < o_len { return Less; }
         if s_len > o_len { return Greater;  }
 
-        for self.data.eachi_reverse |i, elm| {
-            match (*elm, other.data[i]) {
-                (l, r) if l < r => return Less,
-                (l, r) if l > r => return Greater,
-                _               => loop
-            };
+        for self.data.rev_iter().zip(other.data.rev_iter()).advance |(&self_i, &other_i)| {
+            cond!((self_i < other_i) { return Less; }
+                  (self_i > other_i) { return Greater; })
         }
         return Equal;
     }
@@ -421,7 +418,7 @@ impl Integer for BigUint {
             let bn = *b.data.last();
             let mut d = ~[];
             let mut carry = 0;
-            for an.each_reverse |elt| {
+            for an.rev_iter().advance |elt| {
                 let ai = BigDigit::to_uint(carry, *elt);
                 let di = ai / (bn as uint);
                 assert!(di < BigDigit::base);
@@ -648,7 +645,7 @@ impl BigUint {
 
         let mut borrow = 0;
         let mut shifted = ~[];
-        for self.data.each_reverse |elem| {
+        for self.data.rev_iter().advance |elem| {
             shifted = ~[(*elem >> n_bits) | borrow] + shifted;
             borrow = *elem << (BigDigit::bits - n_bits);
         }
diff --git a/src/libextra/par.rs b/src/libextra/par.rs
index 49696a5fa25..23b7cdc0997 100644
--- a/src/libextra/par.rs
+++ b/src/libextra/par.rs
@@ -10,6 +10,7 @@
 
 use core::prelude::*;
 
+use core::iterator::IteratorUtil;
 use core::cast;
 use core::ptr;
 use core::sys;
@@ -122,25 +123,24 @@ pub fn alli<A:Copy + Owned>(
     xs: &[A],
     fn_factory: &fn() -> ~fn(uint, &A) -> bool) -> bool
 {
-    do vec::all(map_slices(xs, || {
+    let mapped = map_slices(xs, || {
         let f = fn_factory();
         let result: ~fn(uint, &[A]) -> bool = |base, slice| {
-            vec::alli(slice, |i, x| {
-                f(i + base, x)
-            })
+            slice.iter().enumerate().all(|(i, x)| f(i + base, x))
         };
         result
-    })) |x| { *x }
+    });
+    mapped.iter().all(|&x| x)
 }
 
 /// Returns true if the function holds for any elements in the vector.
 pub fn any<A:Copy + Owned>(
     xs: &[A],
     fn_factory: &fn() -> ~fn(&A) -> bool) -> bool {
-    do vec::any(map_slices(xs, || {
+    let mapped = map_slices(xs, || {
         let f = fn_factory();
-        let result: ~fn(uint, &[A]) -> bool =
-            |_, slice| vec::any(slice, |x| f(x));
+        let result: ~fn(uint, &[A]) -> bool = |_, slice| slice.iter().any(f);
         result
-    })) |x| { *x }
+    });
+    mapped.iter().any(|&x| x)
 }
diff --git a/src/libextra/sort.rs b/src/libextra/sort.rs
index 420c63efab5..26d1e28e122 100644
--- a/src/libextra/sort.rs
+++ b/src/libextra/sort.rs
@@ -929,11 +929,8 @@ mod test_tim_sort {
     use core::prelude::*;
 
     use sort::tim_sort;
-
-    use core::local_data;
     use core::rand::RngUtil;
     use core::rand;
-    use core::uint;
     use core::vec;
 
     struct CVal {
diff --git a/src/libextra/stats.rs b/src/libextra/stats.rs
index d224777ded7..0cc1ee9a1d7 100644
--- a/src/libextra/stats.rs
+++ b/src/libextra/stats.rs
@@ -12,6 +12,7 @@
 
 use core::prelude::*;
 
+use core::iterator::*;
 use core::vec;
 use core::f64;
 use core::cmp;
@@ -36,17 +37,17 @@ pub trait Stats {
 
 impl<'self> Stats for &'self [f64] {
     fn sum(self) -> f64 {
-        vec::foldl(0.0, self, |p,q| p + *q)
+        self.iter().fold(0.0, |p,q| p + *q)
     }
 
     fn min(self) -> f64 {
         assert!(self.len() != 0);
-        vec::foldl(self[0], self, |p,q| cmp::min(p, *q))
+        self.iter().fold(self[0], |p,q| cmp::min(p, *q))
     }
 
     fn max(self) -> f64 {
         assert!(self.len() != 0);
-        vec::foldl(self[0], self, |p,q| cmp::max(p, *q))
+        self.iter().fold(self[0], |p,q| cmp::max(p, *q))
     }
 
     fn mean(self) -> f64 {
diff --git a/src/libextra/std.rc b/src/libextra/std.rc
index 4e9a547e141..83c0bb516b4 100644
--- a/src/libextra/std.rc
+++ b/src/libextra/std.rc
@@ -148,4 +148,3 @@ pub mod extra {
     pub use serialize;
     pub use test;
 }
-
diff --git a/src/libextra/sync.rs b/src/libextra/sync.rs
index 28a5e5382be..8bbe0afa704 100644
--- a/src/libextra/sync.rs
+++ b/src/libextra/sync.rs
@@ -731,7 +731,6 @@ mod tests {
     use core::cast;
     use core::cell::Cell;
     use core::comm;
-    use core::ptr;
     use core::result;
     use core::task;
     use core::vec;
diff --git a/src/libextra/tempfile.rs b/src/libextra/tempfile.rs
index 6d0bd888195..98c57838072 100644
--- a/src/libextra/tempfile.rs
+++ b/src/libextra/tempfile.rs
@@ -34,7 +34,6 @@ mod tests {
     use core::prelude::*;
 
     use tempfile::mkdtemp;
-    use tempfile;
 
     use core::os;
     use core::str;
diff --git a/src/libextra/time.rs b/src/libextra/time.rs
index 758181980a8..dd3e4f48c63 100644
--- a/src/libextra/time.rs
+++ b/src/libextra/time.rs
@@ -16,6 +16,7 @@ use core::i32;
 use core::int;
 use core::io;
 use core::str;
+use core::iterator::IteratorUtil;
 
 static NSEC_PER_SEC: i32 = 1_000_000_000_i32;
 
@@ -261,7 +262,7 @@ impl Tm {
 priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
     fn match_str(s: &str, pos: uint, needle: &str) -> bool {
         let mut i = pos;
-        for str::each(needle) |ch| {
+        for needle.bytes_iter().advance |ch| {
             if s[i] != ch {
                 return false;
             }
diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs
index ebb0cdc120f..9db3d48a3b8 100644
--- a/src/libextra/treemap.rs
+++ b/src/libextra/treemap.rs
@@ -1034,8 +1034,6 @@ mod test_set {
 
     use super::*;
 
-    use core::vec;
-
     #[test]
     fn test_clear() {
         let mut s = TreeSet::new();
diff --git a/src/libextra/uv_ll.rs b/src/libextra/uv_ll.rs
index 2cb2eea8828..2522f149bf4 100644
--- a/src/libextra/uv_ll.rs
+++ b/src/libextra/uv_ll.rs
@@ -1234,7 +1234,6 @@ mod test {
 
     use core::comm::{SharedChan, stream, GenericChan, GenericPort};
     use core::libc;
-    use core::result;
     use core::str;
     use core::sys;
     use core::task;