Skip to content

Commit

Permalink
Test and update the README
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Feb 23, 2015
1 parent 88cb8cf commit 09caa5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] &&
Expand Down
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
```

Expand Down

0 comments on commit 09caa5a

Please sign in to comment.