Skip to content

Commit

Permalink
test: fix the readme example and test it
Browse files Browse the repository at this point in the history
Instead of manually copying the readme example into an "example" file,
doctest the readme directly.

fixes #153
  • Loading branch information
Stebalien committed Dec 24, 2023
1 parent 98ce8ff commit 5a5aef4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
## Usage

```rust
use cid::multihash::{Code, MultihashDigest};
use multihash_codetable::{Code, MultihashDigest};
use cid::Cid;
use std::convert::TryFrom;

Expand Down
27 changes: 0 additions & 27 deletions examples/readme.rs

This file was deleted.

5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ pub use self::version::Version;
pub use multibase;
pub use multihash;

// Doctest the readme!
#[doc = include_str!("../README.md")]
#[cfg(all(doctest, feature = "std"))]
pub struct ReadmeDoctest;

/// A Cid that contains a multihash with an allocated size of 512 bits.
///
/// This is the same digest size the default multihash code table has.
Expand Down

0 comments on commit 5a5aef4

Please sign in to comment.