Skip to content

Commit ae69c2f

Browse files
pkgwcatamorphism
authored andcommitted
std: Constify the bytes sent to Sha1::input
We are of course never going to modify the data, and this change allows us to accept data from to_bytes::IterBytes types.
1 parent 392708e commit ae69c2f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libstd/sha1.rs

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

78-
fn add_input(st: &Sha1State, msg: &[u8]) {
78+
fn add_input(st: &Sha1State, msg: &[const u8]) {
7979
assert (!st.computed);
80-
for vec::each(msg) |element| {
80+
for vec::each_const(msg) |element| {
8181
st.msg_block[st.msg_block_idx] = *element;
8282
st.msg_block_idx += 1u;
8383
st.len_low += 8u32;
@@ -243,7 +243,7 @@ pub fn sha1() -> Sha1 {
243243
self.h[4] = 0xC3D2E1F0u32;
244244
self.computed = false;
245245
}
246-
fn input(msg: &[u8]) { add_input(&self, msg); }
246+
fn input(msg: &[const u8]) { add_input(&self, msg); }
247247
fn input_str(msg: &str) {
248248
let bs = str::to_bytes(msg);
249249
add_input(&self, bs);

0 commit comments

Comments
 (0)