From 931360fb2bba4656aa944f1a1e91d1ee1c5a5033 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 9 Mar 2015 10:47:56 -0700 Subject: [PATCH] Remove usage of the collections feature --- src/deflate.rs | 2 +- src/gz.rs | 8 ++++---- src/lib.rs | 2 +- src/raw.rs | 6 +++--- src/zlib.rs | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/deflate.rs b/src/deflate.rs index 5154c62b2..ed21bdc4b 100644 --- a/src/deflate.rs +++ b/src/deflate.rs @@ -158,7 +158,7 @@ mod tests { let v = thread_rng().gen_iter::().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; - real.push_all(to_write); + real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } let result = w.finish().unwrap(); diff --git a/src/gz.rs b/src/gz.rs index a6f8a26e3..68d6dd3ef 100644 --- a/src/gz.rs +++ b/src/gz.rs @@ -143,21 +143,21 @@ impl Builder { flg |= FEXTRA; header.push((v.len() >> 0) as u8); header.push((v.len() >> 8) as u8); - header.push_all(&v); + header.extend(v); } None => {} } match filename { Some(filename) => { flg |= FNAME; - header.push_all(filename.as_bytes_with_nul()); + header.extend(filename.as_bytes_with_nul().iter().map(|x| *x)); } None => {} } match comment { Some(comment) => { flg |= FCOMMENT; - header.push_all(comment.as_bytes_with_nul()); + header.extend(comment.as_bytes_with_nul().iter().map(|x| *x)); } None => {} } @@ -497,7 +497,7 @@ mod tests { let v = thread_rng().gen_iter::().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; - real.push_all(to_write); + real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } let result = w.finish().unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 68f28ba3a..4aa10d7e2 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, collections)] +#![feature(io)] #![deny(missing_docs)] #![feature(unsafe_destructor)] #![cfg_attr(test, deny(warnings))] diff --git a/src/raw.rs b/src/raw.rs index 8a11dff2b..6af91545f 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -23,7 +23,7 @@ pub struct DecoderReader(InnerRead); struct InnerRead { inner: R, stream: Stream, - buf: Box<[u8]>, + buf: Vec, // TODO: this should be Box<[u8]> pos: usize, cap: usize, } @@ -161,7 +161,7 @@ impl EncoderReader { EncoderReader(InnerRead { inner: w, stream: Stream::new_compress(level, raw), - buf: buf.into_boxed_slice(), + buf: buf, cap: 0, pos: 0, }) @@ -181,7 +181,7 @@ impl DecoderReader { DecoderReader(InnerRead { inner: r, stream: Stream::new_decompress(raw), - buf: buf.into_boxed_slice(), + buf: buf, pos: 0, cap: 0, }) diff --git a/src/zlib.rs b/src/zlib.rs index df13cd312..93ab75cd7 100644 --- a/src/zlib.rs +++ b/src/zlib.rs @@ -158,7 +158,7 @@ mod tests { let v = thread_rng().gen_iter::().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; - real.push_all(to_write); + real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } let result = w.finish().unwrap();