From 09caa5a37cfee8583d8df7f2f807c9b8f6a4821a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 23 Feb 2015 01:28:17 -0800 Subject: [PATCH] Test and update the README --- .travis.yml | 1 + README.md | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 82f56b00e..b1d28ee8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ sudo: false script: - cargo build --verbose - cargo test --verbose + - rustdoc --test README.md -L target -L target/deps - cargo doc after_success: | [ $TRAVIS_BRANCH = master ] && diff --git a/README.md b/README.md index f63cb07a1..b00b845a3 100644 --- a/README.md +++ b/README.md @@ -15,23 +15,21 @@ Supported formats: ```toml # Cargo.toml -[dependencies.flate2] -git = "https://github.com/alexcrichton/flate2-rs" +[dependencies] +flate2 = "0.2" ``` ## Compression ```rust -# #![feature(io)] extern crate flate2; -use std::old_io::MemWriter; -use flate2::CompressionLevel; -use flate2::writer::ZlibEncoder; +use std::io::prelude::*; +use flate2::Compression; +use flate2::write::ZlibEncoder; -# #[allow(unused_must_use)] fn main() { - let mut e = ZlibEncoder::new(MemWriter::new(), CompressionLevel::Default); + let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); e.write(b"foo"); e.write(b"bar"); let compressed_bytes = e.finish(); @@ -41,15 +39,16 @@ fn main() { ## Decompression ```rust,no_run -# #![feature(io)] extern crate flate2; -use std::old_io::BufReader; -use flate2::reader::GzDecoder; +use std::io::prelude::*; +use flate2::read::GzDecoder; fn main() { - let mut d = GzDecoder::new(BufReader::new(b"...")); - println!("{}", d.read_to_string().unwrap()); + let mut d = GzDecoder::new(b"...").unwrap(); + let mut s = String::new(); + d.read_to_string(&mut s).unwrap(); + println!("{}", s); } ```