Skip to content

Commit 49cfef7

Browse files
committed
Auto merge of #105 - GuillaumeGomez:doc-comment, r=Amanieu
Add doc-comment to check README file code examples Considering that there is actually only one example, don't hesitate to close it if you find it not worth it.
2 parents fe512c2 + a82da0a commit 49cfef7

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ rand = "0.5.1"
3131
rayon = "1.0"
3232
rustc-hash = "1.0"
3333
serde_test = "1.0"
34+
doc-comment = "0.3.1"
3435

3536
[features]
3637
default = []

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The original C++ version of SwissTable can be found [here], and this
3232

3333
Compared to `std::collections::HashMap`:
3434

35-
```
35+
```text
3636
name stdhash ns/iter hashbrown ns/iter diff ns/iter diff % speedup
3737
find_existing 23,831 2,935 -20,896 -87.68% x 8.12
3838
find_nonexisting 25,326 2,283 -23,043 -90.99% x 11.09
@@ -45,7 +45,7 @@ Compared to `std::collections::HashMap`:
4545

4646
Compared to `rustc_hash::FxHashMap` (standard `HashMap` using `FxHash` instead of `SipHash`):
4747

48-
```
48+
```text
4949
name fxhash ns/iter hashbrown ns/iter diff ns/iter diff % speedup
5050
find_existing 5,951 2,935 -3,016 -50.68% x 2.03
5151
find_nonexisting 4,637 2,283 -2,354 -50.77% x 2.03
@@ -69,7 +69,9 @@ Then:
6969

7070
```rust
7171
use hashbrown::HashMap;
72+
7273
let mut map = HashMap::new();
74+
map.insert(1, "one");
7375
```
7476

7577
This crate has the following Cargo features:

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
ptr_offset_from,
1919
test,
2020
core_intrinsics,
21-
dropck_eyepatch
21+
dropck_eyepatch,
22+
cfg_doctest,
2223
)
2324
)]
2425
#![warn(missing_docs)]
@@ -35,6 +36,10 @@ extern crate alloc;
3536
#[cfg(not(has_extern_crate_alloc))]
3637
extern crate std as alloc;
3738

39+
#[cfg(feature = "nightly")]
40+
#[cfg(doctest)]
41+
doc_comment::doctest!("../README.md");
42+
3843
#[macro_use]
3944
mod macros;
4045

0 commit comments

Comments
 (0)