aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/hash.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/hash.rs')
-rw-r--r--src/crypto/hash.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/crypto/hash.rs b/src/crypto/hash.rs
index 2a181526..1f8a3936 100644
--- a/src/crypto/hash.rs
+++ b/src/crypto/hash.rs
@@ -1,10 +1,11 @@
use libc::c_uint;
use std::ptr;
use std::io;
+use std::iter::repeat;
use ffi;
-#[deriving(Copy)]
+#[derive(Copy)]
pub enum HashType {
MD5,
SHA1,
@@ -101,7 +102,7 @@ impl Hasher {
* initialization and its context for reuse
*/
pub fn finalize_reuse(self) -> (Vec<u8>, HasherContext) {
- let mut res = Vec::from_elem(self.len, 0u8);
+ let mut res = repeat(0u8).take(self.len).collect::<Vec<_>>();
unsafe {
ffi::EVP_DigestFinal_ex(self.ctx.ptr, res.as_mut_ptr(), ptr::null_mut())
};