diff --git a/src/gz.rs b/src/gz.rs index c313aa95f..a6f8a26e3 100644 --- a/src/gz.rs +++ b/src/gz.rs @@ -9,7 +9,6 @@ use std::io::prelude::*; use std::io; use std::iter::repeat; use std::mem; -use std::slice::bytes; use Compression; use crc::{CrcReader, Crc}; @@ -144,7 +143,7 @@ impl Builder { flg |= FEXTRA; header.push((v.len() >> 0) as u8); header.push((v.len() >> 8) as u8); - header.push_all(v.as_slice()); + header.push_all(&v); } None => {} } @@ -284,7 +283,9 @@ impl EncoderReader { fn copy(into: &mut [u8], from: &[u8], pos: &mut usize) -> usize { let min = cmp::min(into.len(), from.len() - *pos); - bytes::copy_memory(into, &from[*pos .. *pos + min]); + for (slot, val) in into.iter_mut().zip(from[*pos..*pos + min].iter()) { + *slot = *val; + } *pos += min; return min } @@ -450,15 +451,15 @@ impl Read for DecoderReader { impl Header { /// Returns the `filename` field of this gzip stream's header, if present. pub fn filename(&self) -> Option<&[u8]> { - self.filename.as_ref().map(|s| s.as_slice()) + self.filename.as_ref().map(|s| &s[..]) } /// Returns the `extra` field of this gzip stream's header, if present. pub fn extra(&self) -> Option<&[u8]> { - self.extra.as_ref().map(|s| s.as_slice()) + self.extra.as_ref().map(|s| &s[..]) } /// Returns the `comment` field of this gzip stream's header, if present. pub fn comment(&self) -> Option<&[u8]> { - self.comment.as_ref().map(|s| s.as_slice()) + self.comment.as_ref().map(|s| &s[..]) } /// Returns the `mtime` field of this gzip stream's header, if present. pub fn mtime(&self) -> u32 { self.mtime } @@ -494,7 +495,7 @@ mod tests { let mut real = Vec::new(); let mut w = EncoderWriter::new(Vec::new(), Default); let v = thread_rng().gen_iter::().take(1024).collect::>(); - for _ in range(0, 200) { + for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; real.push_all(to_write); w.write_all(to_write).unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 38ddce416..68f28ba3a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,7 @@ //! already existing stream to chain construction. #![doc(html_root_url = "http://alexcrichton.com/flate2-rs")] -#![feature(io, core, collections)] +#![feature(io, collections)] #![deny(missing_docs)] #![feature(unsafe_destructor)] #![cfg_attr(test, deny(warnings))] diff --git a/src/stream.rs b/src/stream.rs index f3e5c128f..bd64bef82 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -22,7 +22,7 @@ pub enum Flush { } #[doc(hidden)] -pub trait Direction: marker::MarkerTrait { +pub trait Direction: marker::PhantomFn { unsafe fn destroy(stream: *mut ffi::mz_stream) -> c_int; }