Skip to content

Commit 62dc4e0

Browse files
committed
vec: remove each_const
An Iterator implementation can be made for &const [T] if it turns out to be necessary for some use case.
1 parent 77ae7ec commit 62dc4e0

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

src/libextra/sha1.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use core::vec;
3636
/// The SHA-1 interface
3737
trait Sha1 {
3838
/// Provide message input as bytes
39-
fn input(&mut self, &const [u8]);
39+
fn input(&mut self, &[u8]);
4040
/// Provide message input as string
4141
fn input_str(&mut self, &str);
4242
/**
@@ -74,9 +74,9 @@ pub fn sha1() -> @Sha1 {
7474
computed: bool,
7575
work_buf: @mut ~[u32]};
7676

77-
fn add_input(st: &mut Sha1State, msg: &const [u8]) {
77+
fn add_input(st: &mut Sha1State, msg: &[u8]) {
7878
assert!((!st.computed));
79-
for vec::each_const(msg) |element| {
79+
for msg.iter().advance |element| {
8080
st.msg_block[st.msg_block_idx] = *element;
8181
st.msg_block_idx += 1u;
8282
st.len_low += 8u32;
@@ -242,7 +242,7 @@ pub fn sha1() -> @Sha1 {
242242
self.h[4] = 0xC3D2E1F0u32;
243243
self.computed = false;
244244
}
245-
fn input(&mut self, msg: &const [u8]) { add_input(self, msg); }
245+
fn input(&mut self, msg: &[u8]) { add_input(self, msg); }
246246
fn input_str(&mut self, msg: &str) {
247247
add_input(self, msg.as_bytes());
248248
}

src/libstd/vec.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,21 +1427,6 @@ pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool {
14271427
return !broke;
14281428
}
14291429

1430-
/// Like `each()`, but for the case where you have a vector that *may or may
1431-
/// not* have mutable contents.
1432-
#[inline]
1433-
pub fn each_const<T>(v: &const [T], f: &fn(elem: &const T) -> bool) -> bool {
1434-
let mut i = 0;
1435-
let n = v.len();
1436-
while i < n {
1437-
if !f(&const v[i]) {
1438-
return false;
1439-
}
1440-
i += 1;
1441-
}
1442-
return true;
1443-
}
1444-
14451430
/**
14461431
* Iterates over a vector's elements and indices
14471432
*

0 commit comments

Comments
 (0)