about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-06-17 16:32:06 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-06-21 03:20:22 -0400
commit62dc4e0d4cebc390de4053da881a74b9e72c52e6 (patch)
treee4b1029fb89ef03d5fc5bf730ce3cba796fd11e0
parent77ae7ec8d874270af0741b5c1f52cf9d58248b86 (diff)
downloadrust-62dc4e0d4cebc390de4053da881a74b9e72c52e6.tar.gz
rust-62dc4e0d4cebc390de4053da881a74b9e72c52e6.zip
vec: remove each_const
An Iterator implementation can be made for &const [T] if it turns out
to be necessary for some use case.
-rw-r--r--src/libextra/sha1.rs8
-rw-r--r--src/libstd/vec.rs15
2 files changed, 4 insertions, 19 deletions
diff --git a/src/libextra/sha1.rs b/src/libextra/sha1.rs
index 7c4b3f4ce39..78c4f5f13ec 100644
--- a/src/libextra/sha1.rs
+++ b/src/libextra/sha1.rs
@@ -36,7 +36,7 @@ use core::vec;
 /// The SHA-1 interface
 trait Sha1 {
     /// Provide message input as bytes
-    fn input(&mut self, &const [u8]);
+    fn input(&mut self, &[u8]);
     /// Provide message input as string
     fn input_str(&mut self, &str);
     /**
@@ -74,9 +74,9 @@ pub fn sha1() -> @Sha1 {
           computed: bool,
           work_buf: @mut ~[u32]};
 
-    fn add_input(st: &mut Sha1State, msg: &const [u8]) {
+    fn add_input(st: &mut Sha1State, msg: &[u8]) {
         assert!((!st.computed));
-        for vec::each_const(msg) |element| {
+        for msg.iter().advance |element| {
             st.msg_block[st.msg_block_idx] = *element;
             st.msg_block_idx += 1u;
             st.len_low += 8u32;
@@ -242,7 +242,7 @@ pub fn sha1() -> @Sha1 {
             self.h[4] = 0xC3D2E1F0u32;
             self.computed = false;
         }
-        fn input(&mut self, msg: &const [u8]) { add_input(self, msg); }
+        fn input(&mut self, msg: &[u8]) { add_input(self, msg); }
         fn input_str(&mut self, msg: &str) {
             add_input(self, msg.as_bytes());
         }
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index 7f683d0070f..1131abfafa8 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -1427,21 +1427,6 @@ pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool {
     return !broke;
 }
 
-/// Like `each()`, but for the case where you have a vector that *may or may
-/// not* have mutable contents.
-#[inline]
-pub fn each_const<T>(v: &const [T], f: &fn(elem: &const T) -> bool) -> bool {
-    let mut i = 0;
-    let n = v.len();
-    while i < n {
-        if !f(&const v[i]) {
-            return false;
-        }
-        i += 1;
-    }
-    return true;
-}
-
 /**
  * Iterates over a vector's elements and indices
  *