From ed9fb1a057aca4e0988f23d63a242a4adfe20656 Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 29 Aug 2023 11:41:53 +0900 Subject: [PATCH] feat: readme doc rpt --- content/blog/rust-pro-tips-collection.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/content/blog/rust-pro-tips-collection.md b/content/blog/rust-pro-tips-collection.md index bcd3020..2a40ab5 100644 --- a/content/blog/rust-pro-tips-collection.md +++ b/content/blog/rust-pro-tips-collection.md @@ -12,6 +12,20 @@ license: This is a collection of Rust "pro tips" that I've collected, most of which have been [posted on Twitter](https://twitter.com/search?q=%23RustProTip%20%40sudo_build&src=typed_query&f=top). I'll keep updating this post as I write more. Tips are ordered in reverse chronological order, with the most recent ones at the top. +## 29. Include README in documentation + + + +Insert the README into a crate's documentation by putting `#![doc = include_str!("../README.md")]` in `lib.rs`. This can help avoid duplicating information between the README and the documentation, and will also test README examples as doctests. + +```rust +// lib.rs +#![doc = include_str!("../README.md")] +``` + +[Docs](https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html) \ +[Documentation from a crate that does this](https://docs.rs/size-trait/) + ## 28. Workspace dependencies [Tweet](https://twitter.com/sudo_build/status/1690286028555423744) [Toot](https://infosec.exchange/@hatchet/110875801320226379)