Skip to content

Commit

Permalink
doc: update docs in a few places
Browse files Browse the repository at this point in the history
This fixes some examples, including the README, and adds doc_comment to
check that the README remains up to date.
  • Loading branch information
BurntSushi committed Feb 14, 2020
1 parent cdd6702 commit de59ac7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ debug = true

[profile.test]
opt-level = 3

[dev-dependencies]
doc-comment = "0.3.1"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn main() {

let mut rdr = stdin.lock();
// Wrap the stdout writer in a Snappy writer.
let mut wtr = snap::Writer::new(stdout.lock());
let mut wtr = snap::write::FrameEncoder::new(stdout.lock());
io::copy(&mut rdr, &mut wtr).expect("I/O operation failed");
}
```
Expand Down
8 changes: 4 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use std::result;
/// A convenient type alias for `Result<T, snap::Error>`.
pub type Result<T> = result::Result<T, Error>;

/// `IntoInnerError` occurs when consuming a `Writer` fails.
/// `IntoInnerError` occurs when consuming an encoder fails.
///
/// Consuming the `Writer` causes a flush to happen. If the flush fails, then
/// this error is returned, which contains both the original `Writer` and
/// the error that occurred.
/// Consuming the encoder causes a flush to happen. If the flush fails, then
/// this error is returned, which contains both the original encoder and the
/// error that occurred.
///
/// The type parameter `W` is the unconsumed writer.
pub struct IntoInnerError<W> {
Expand Down
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ you automatically convert a Snappy error to an `std::io::Error` (when using
This program reads data from `stdin`, compresses it and emits it to `stdout`.
This example can be found in `examples/compress.rs`:
```rust,ignore
```no_run
use std::io;
fn main() {
Expand All @@ -57,7 +57,7 @@ fn main() {
let mut rdr = stdin.lock();
// Wrap the stdout writer in a Snappy writer.
let mut wtr = snap::Writer::new(stdout.lock());
let mut wtr = snap::write::FrameEncoder::new(stdout.lock());
io::copy(&mut rdr, &mut wtr).expect("I/O operation failed");
}
```
Expand All @@ -67,7 +67,7 @@ fn main() {
This program reads data from `stdin`, decompresses it and emits it to `stdout`.
This example can be found in `examples/decompress.rs`:
```rust,ignore
```no_run
use std::io;
fn main() {
Expand All @@ -84,6 +84,9 @@ fn main() {

#![deny(missing_docs)]

#[cfg(test)]
doc_comment::doctest!("../README.md");

pub use crate::error::{Error, Result};

/// We don't permit compressing a block bigger than what can fit in a u32.
Expand Down
4 changes: 2 additions & 2 deletions src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ use crate::MAX_BLOCK_SIZE;
pub struct FrameEncoder<W: io::Write> {
/// Our main internal state, split out for borrowck reasons (happily paid).
///
/// Also, it's an `Option` so we can move out of it even though `Writer`
/// impls `Drop`.
/// Also, it's an `Option` so we can move out of it even though
/// `FrameEncoder` impls `Drop`.
inner: Option<Inner<W>>,
/// Our buffer of uncompressed bytes. This isn't part of `inner` because
/// we may write bytes directly from the caller if the given buffer was
Expand Down

0 comments on commit de59ac7

Please sign in to comment.